vigra - ParallelOptions Class Reference

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

| ParallelOptions Class Reference Parallel Processing |

Option base class for parallel algorithms. More...

`#include <vigra/threadpool.hxx>`

Inheritance diagram for ParallelOptions:

## Public Types
enum | { Auto = -1, Nice = -2, NoThreads = 0 }

## Public Member Functions
int | getActualNumThreads () const
| Get desired number of threads. More...
int | getNumThreads () const
| Get desired number of threads. More...
ParallelOptions & | numThreads (const int n)
| Set the number of threads or one of the constants `Auto`, `Nice` and `NoThreads`. More...

## Detailed Description

Option base class for parallel algorithms.

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

## Member Enumeration Documentation

anonymous enum

Constants for special settings.

Enumerator
Auto | Determine number of threads automatically (from `threading::thread::hardware_concurrency()`)
Nice | Use half as many threads as `Auto` would.
NoThreads | Switch off multi-threading (i.e. execute tasks sequentially)

## Member Function Documentation

int getNumThreads | ( |  | ) | const

Get desired number of threads.

Note: This function may return 0, which means that multi-threading shall be switched off entirely. If an algorithm receives this value, it should revert to a sequential implementation. In contrast, if `numThread() == 1`, the parallel algorithm version shall be executed with a single thread.

int getActualNumThreads | ( |  | ) | const

Get desired number of threads.

In contrast to `numThread()`, this will always return a value `>=1`.

ParallelOptions& numThreads | ( | const int | n | ) |

Set the number of threads or one of the constants `Auto`, `Nice` and `NoThreads`.

Default: `ParallelOptions::Auto` (use system default)

This setting is ignored if the preprocessor flag `VIGRA_SINGLE_THREADED` is defined. Then, the number of threads is set to 0 and all tasks revert to sequential algorithm implementations. The same can be achieved at runtime by passing `n = 0` to this function. In contrast, passing `n = 1` causes the parallel algorithm versions to be executed with a single thread. Both possibilities are mainly useful for debugging.

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.1 (Fri May 19 2017)