64 Task* taskHead =
nullptr;
65 Task* taskTail =
nullptr;
67 size_t numRunningTasks = 0;
68 size_t numWorkerThreads = 0;
74 bool stopRequested =
false;
A native OS condition variable.
Definition Threading.h:63
Wraps function pointers, member functions and lambdas without ever allocating.
Definition Function.h:19
A native OS mutex to synchronize access to shared resources.
Definition Threading.h:28
An ascii string used as boolean result. SC_TRY macro forwards errors to caller.
Definition Result.h:12
A small task containing a function to execute that can be queued in the thread pool.
Definition ThreadPool.h:19
Function< void()> function
Function that will be executed during the task.
Definition ThreadPool.h:21
Simple thread pool that executes tasks in a fixed number of worker threads.
Definition ThreadPool.h:41
Result destroy()
Destroy the thread pool created previously with ThreadPool::create.
Result queueTask(Task &task)
Queue a task (that should not be already in use)
Result waitForTask(Task &task)
Blocks execution until all queued and pending tasks will be fully completed.
Result create(size_t workerThreads)
Create a thread pool with the requested number of worker threads.
Result waitForAllTasks()
Blocks execution until all queued and pending tasks will be fully completed.