|
quickpool
0.2.0
An easy-to-use, header-only work stealing thread pool in C++11
|
A work stealing thread pool. More...
#include <quickpool.hpp>
Public Member Functions | |
| ThreadPool () | |
| constructs a thread pool with as many workers as there are cores. | |
| ThreadPool (size_t n_workers) | |
| ThreadPool (ThreadPool &&)=delete | |
| ThreadPool (const ThreadPool &)=delete | |
| ThreadPool & | operator= (const ThreadPool &)=delete |
| ThreadPool & | operator= (ThreadPool &&other)=delete |
| template<class Function , class... Args> | |
| void | push (Function &&f, Args &&... args) |
| pushes a job to the thread pool. More... | |
| template<class Function , class... Args> | |
| auto | async (Function &&f, Args &&... args) -> std::future< decltype(f(args...))> |
| executes a job asynchronously the global thread pool. More... | |
| void | wait () |
| waits for all jobs currently running on the global thread pool. | |
Static Public Member Functions | |
| static ThreadPool & | global_instance () |
| returns a reference to the global thread pool instance. | |
A work stealing thread pool.
Definition at line 330 of file quickpool.hpp.
|
inlineexplicit |
constructs a thread pool.
| n_workers | number of worker threads to create; defaults to number of available (virtual) hardware cores. |
Definition at line 341 of file quickpool.hpp.
|
inline |
executes a job asynchronously the global thread pool.
| f | a function. |
| args | (optional) arguments passed to f. |
std::future for the task. Call future.get() to retrieve the results at a later point in time (blocking). Definition at line 399 of file quickpool.hpp.
|
inline |
pushes a job to the thread pool.
| f | a function. |
| args | (optional) arguments passed to f. |
Definition at line 384 of file quickpool.hpp.
1.8.17