[ VIGRA Homepage | Function Index | Class Index | Namespaces | File List | Main Page ]
ThreadPool Class Reference |
Thread pool class to manage a set of parallel workers. More...
#include <vigra/threadpool.hxx>
Public Member Functions | |
template<class F > | |
threading::future< void > | enqueue (F &&f) |
template<class F > | |
auto | enqueueReturning (F &&f) -> threading::future< decltype(f(0))> |
size_t | nThreads () const |
ThreadPool (const ParallelOptions &options) | |
ThreadPool (const int n) | |
void | waitFinished () |
~ThreadPool () | |
Thread pool class to manage a set of parallel workers.
#include <vigra/threadpool.hxx>
Namespace: vigra
ThreadPool | ( | const ParallelOptions & | options | ) |
Create a thread pool from ParallelOptions. The constructor just launches the desired number of workers. If the number of threads is zero, no workers are started, and all tasks will be executed in synchronously in the present thread.
ThreadPool | ( | const int | n | ) |
Create a thread pool with n threads. The constructor just launches the desired number of workers. If
ParallelOptions::Auto
, the number of threads is determined by threading::thread::hardware_concurrency()
. ParallelOptions::Nice
will create half as many threads. If n = 0
, no workers are started, and all tasks will be executed synchronously in the present thread. If the preprocessor flag VIGRA_SINGLE_THREADED
is defined, the number of threads is always set to zero (i.e. synchronous execution), regardless of the value of void waitFinished | ( | ) |
Block until all tasks are finished.
size_t nThreads | ( | ) | const |
Return the number of worker threads.
© Ullrich Köthe (ullrich.koethe@iwr.uni-heidelberg.de) |
html generated using doxygen and Python
|