cubos::core::thread::ThreadPool class final

Manages a pool of threads, to which tasks can be submitted.

Constructors, destructors, conversion operators

ThreadPool(std::size_t numThreads)
Constructs a pool with numThreads, starting them immediately.

Public functions

void addTask(std::function<void()> task)
Adds a task to the thread pool. Starts when a thread becomes available.
void wait()
Blocks until all tasks finish.

Function documentation

cubos::core::thread::ThreadPool::ThreadPool(std::size_t numThreads)

Constructs a pool with numThreads, starting them immediately.

Parameters
numThreads Number of threads to create.

void cubos::core::thread::ThreadPool::addTask(std::function<void()> task)

Adds a task to the thread pool. Starts when a thread becomes available.

Parameters
task Task to add.