4#include "../Threading/Threading.h"
8struct SC_THREADING_EXPORT ThreadPool;
68 Task* taskHead =
nullptr;
69 Task* taskTail =
nullptr;
71 size_t numRunningTasks = 0;
72 size_t numWorkerThreads = 0;
78 bool stopRequested =
false;
A native OS condition variable.
Definition Threading.h:72
A native OS mutex to synchronize access to shared resources.
Definition Threading.h:37
Threading result retaining optional native and backend-stage details.
Definition ThreadingError.h:49
A small task containing a function to execute that can be queued in the thread pool.
Definition ThreadPool.h:16
Function< void()> function
Function that will be executed during the task.
Definition ThreadPool.h:18
Function< void()> afterRelease
Optional worker notification after an executed task node is released.
Definition ThreadPool.h:24
Simple thread pool that executes tasks in a fixed number of worker threads.
Definition ThreadPool.h:45
ResultThreading waitForTask(Task &task)
Blocks until this task's function finishes and its node is released, before its optional notification...
ResultThreading destroy()
Destroy the thread pool created previously with ThreadPool::create.
ResultThreading waitForAllTasks()
Blocks execution until all queued tasks and their afterRelease notifications have completed.
ResultThreading create(size_t workerThreads)
Create a thread pool with the requested number of worker threads.
ResultThreading queueTask(Task &task)
Queue a task (that should not be already in use)