[ VIGRA Homepage | Function Index | Class Index | Namespaces | File List | Main Page ]

| ThreadPool Class Reference Parallel Processing |

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 ()

## Detailed Description

Thread pool class to manage a set of parallel workers.

#include <vigra/threadpool.hxx>
Namespace: vigra

## Constructor & Destructor Documentation

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

- n is `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
- n. This is useful for debugging.

## Member Function Documentation

void waitFinished | ( |  | ) |

Block until all tasks are finished.

size_t nThreads | ( |  | ) | const

Return the number of worker threads.

The documentation for this class was generated from the following file:

- vigra/threadpool.hxx

© Ullrich Köthe (ullrich.koethe@iwr.uni-heidelberg.de) Heidelberg Collaboratory for Image Processing, University of Heidelberg, Germany | html generated using doxygen and Python vigra 1.11.0 (Fri May 19 2017)