Work-stealing threadpool.
More...
#include <threadpool.hpp>
|
| Threadpool (unsigned nw=0) |
| Construct a new Threadpool object. More...
|
|
| ~Threadpool () |
| Destroy the Threadpool object.
|
|
size_t | get_number_workers () const |
| Get the number of worker threads. More...
|
|
template<class F , class... Args> |
auto | submit (F &&f, Args &&...args) -> std::future< typename std::result_of< F(Args...)>::type > |
| Submit work to the threadpool. This function takes a function and its arguments and returns a future that will contain the return value of the function. This can be used to wait for the threadpool to run the task. More...
|
|
Work-stealing threadpool.
◆ Threadpool()
ca::Threadpool::Threadpool |
( |
unsigned |
nw = 0 | ) |
|
Construct a new Threadpool object.
- Parameters
-
nw | number of workers. If 0 hardwareconcurrency is used. (default 0) |
◆ get_number_workers()
size_t ca::Threadpool::get_number_workers |
( |
| ) |
const |
Get the number of worker threads.
- Returns
- size_t the number of worker threads.
◆ submit()
template<class F , class... Args>
auto ca::Threadpool::submit |
( |
F && |
f, |
|
|
Args &&... |
args |
|
) |
| -> std::future<typename std::result_of<F(Args...)>::type>
|
|
inline |
Submit work to the threadpool. This function takes a function and its arguments and returns a future that will contain the return value of the function. This can be used to wait for the threadpool to run the task.
- Template Parameters
-
F | function type. |
Args | args type. |
- Parameters
-
f | function to execute. |
args | argument to pass to the function. |
- Returns
- std::future<typename std::result_of<F(Args...)>::type> future that will contain the result of the function.
The documentation for this class was generated from the following files: