#include </opt/build/repo/nap/utility/src/utility/threading.h>
Public Member Functions | |
ThreadPool (int numberOfThreads=1, int maxQueueItems=20, bool realTimePriority=false) | |
~ThreadPool () | |
void | execute (TaskQueue::Task task) |
void | shutDown () |
void | resize (int numberOfThreads) |
int | getThreadCount () const |
int | getTaskCount () const |
bool | isStopping () const |
A pool of threads that can be used to perform multiple tasks at the same time
ThreadPool | ( | int | numberOfThreads = 1 , |
int | maxQueueItems = 20 , |
||
bool | realTimePriority = false |
||
) |
~ThreadPool | ( | ) |
void execute | ( | TaskQueue::Task | task | ) |
Enqueues a task to be performed on the next idle thread.
int getTaskCount | ( | ) | const |
Returns an estimate of the total number of tasks currently in the queue. This estimate is only accurate if the queue has completely stabilized before it is called (i.e. all enqueue and dequeue operations have completed and their memory effects are visible on the calling thread, and no further operations start while this method is being called). Thread-safe.
int getThreadCount | ( | ) | const |
Returns the number of threads in the pool.
bool isStopping | ( | ) | const |
Returns whether this thread is shutting down.
void resize | ( | int | numberOfThreads | ) |
Resizes the number of threads in the pool, joins and exits all existing threads first!
void shutDown | ( | ) |
Sets stopping to true and joins and exits all threads in the pool.