Aether
SDL2 based UI Framework for NX
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
Aether::ThreadPool Class Reference

Basic Thread Pool implemented as a singleton. More...

#include <ThreadPool.hpp>

Classes

class  Job
 Abstract class representing a job for the ThreadPool. It is designed to be inherited to define the job. More...
 

Public Types

enum  Importance { Normal, High }
 Enumeration of job importance levels.
 

Public Member Functions

 ThreadPool (ThreadPool &)=delete
 Prevent copying.
 
void operator= (const ThreadPool &)=delete
 Prevent assigning.
 
size_t maxConcurrentJobs ()
 Returns the maximum number of jobs that can be executed concurrently. More...
 
int queueJob (Job *job, const Importance importance)
 Adds a job to the queue. The job object is deleted once it is complete. More...
 
void removeOrWaitForJob (int id)
 Removes the requested job from the queue, or waits until the job is completed if already running. Does nothing if the id is not found. More...
 

Static Public Member Functions

static ThreadPoolgetInstance ()
 Returns the instance of the ThreadPool. One is created if it does not already exist. More...
 

Detailed Description

Basic Thread Pool implemented as a singleton.

Note
This is primarily used for texture generation, therefore use for your own tasks is not guaranteed to be a good idea!

Member Function Documentation

◆ getInstance()

static ThreadPool* Aether::ThreadPool::getInstance ( )
static

Returns the instance of the ThreadPool. One is created if it does not already exist.

Returns
ThreadPool instance

◆ maxConcurrentJobs()

size_t Aether::ThreadPool::maxConcurrentJobs ( )

Returns the maximum number of jobs that can be executed concurrently.

Returns
Maximum number of concurrent jobs (threads)

◆ queueJob()

int Aether::ThreadPool::queueJob ( Job job,
const Importance  importance 
)

Adds a job to the queue. The job object is deleted once it is complete.

Parameters
jobJob to queue
importanceThe importance of the job (see Importance)
Returns
ID of job

◆ removeOrWaitForJob()

void Aether::ThreadPool::removeOrWaitForJob ( int  id)

Removes the requested job from the queue, or waits until the job is completed if already running. Does nothing if the id is not found.

Parameters
idID of job to wait for

The documentation for this class was generated from the following file: