|
quickpool
0.2.0
An easy-to-use, header-only work stealing thread pool in C++11
|
An easy-to-use, header-only work stealing thread pool in C++11.
Basic usage is demonstrated below. See the API documentation for more details.
The easiest method is to use the quickpool::push(), quickpool::async(), and quickpool::wait() functions. They give access to a global thread pool that is only instantiated once with as many threads as there are cores.
If a task also returns a result, use async(), which returns a std::future for the result.
Both push() and async() can also be called with extra arguments passed to the function.
A ThreadPool can also be set up manually, with an arbitrary number of threads. When the pool goes out of scope, all threads joined.
In general, the pool may process the tasks in any order. Synchronization between tasks (e.g., one thread waiting intermediate results) must be done manually. Standard tools are std::mutex and std::condition_variable. quickpool exposes another synchronization primitive, TodoList, that may be useful.
You can also add items on the fly using TodoList::add().
1.8.17