Launcher object locking a subset of threads (or all threads) in a thread pool to perform parallel execution of the job.
More...
#include <OSD_ThreadPool.hxx>
|
| Launcher (OSD_ThreadPool &thePool, int theMaxThreads=-1) |
| Lock specified number of threads from the thread pool. If thread pool is already locked by another user, Launcher will lock as many threads as possible (if none will be locked, then single threaded execution will be done).
|
|
| ~Launcher () |
| Release threads.
|
|
bool | HasThreads () const |
| Return TRUE if at least 2 threads have been locked for parallel execution (including self-thread); otherwise, the functor will be executed within the caller thread.
|
|
int | NbThreads () const |
| Return amount of locked threads; >= 1.
|
|
int | LowerThreadIndex () const |
| Return the lower thread index.
|
|
int | UpperThreadIndex () const |
| Return the upper thread index (last index is reserved for the self-thread).
|
|
template<typename Functor > |
void | Perform (int theBegin, int theEnd, const Functor &theFunctor) |
| Simple primitive for parallelization of "for" loops, e.g.:
|
|
void | Release () |
| Release threads before Launcher destruction.
|
|
Launcher object locking a subset of threads (or all threads) in a thread pool to perform parallel execution of the job.
◆ Launcher()
OSD_ThreadPool::Launcher::Launcher |
( |
OSD_ThreadPool & | thePool, |
|
|
int | theMaxThreads = -1 ) |
Lock specified number of threads from the thread pool. If thread pool is already locked by another user, Launcher will lock as many threads as possible (if none will be locked, then single threaded execution will be done).
- Parameters
-
◆ ~Launcher()
OSD_ThreadPool::Launcher::~Launcher |
( |
| ) |
|
|
inline |
◆ HasThreads()
bool OSD_ThreadPool::Launcher::HasThreads |
( |
| ) |
const |
|
inline |
Return TRUE if at least 2 threads have been locked for parallel execution (including self-thread); otherwise, the functor will be executed within the caller thread.
◆ LowerThreadIndex()
int OSD_ThreadPool::Launcher::LowerThreadIndex |
( |
| ) |
const |
|
inline |
Return the lower thread index.
◆ NbThreads()
int OSD_ThreadPool::Launcher::NbThreads |
( |
| ) |
const |
|
inline |
Return amount of locked threads; >= 1.
◆ Perform()
template<typename Functor >
void OSD_ThreadPool::Launcher::Perform |
( |
int | theBegin, |
|
|
int | theEnd, |
|
|
const Functor & | theFunctor ) |
|
inline |
Simple primitive for parallelization of "for" loops, e.g.:
for (int anIter = theBegin; anIter < theEnd; ++anIter) {}
- Parameters
-
theBegin | the first data index (inclusive) |
theEnd | the last data index (exclusive) |
theFunctor | functor providing an interface "void operator(int theThreadIndex, int theDataIndex){}" performing task for specified index |
◆ perform()
void OSD_ThreadPool::Launcher::perform |
( |
JobInterface & | theJob | ) |
|
|
protected |
◆ Release()
void OSD_ThreadPool::Launcher::Release |
( |
| ) |
|
Release threads before Launcher destruction.
◆ run()
Initialize job and start threads.
◆ UpperThreadIndex()
int OSD_ThreadPool::Launcher::UpperThreadIndex |
( |
| ) |
const |
|
inline |
Return the upper thread index (last index is reserved for the self-thread).
◆ wait()
void OSD_ThreadPool::Launcher::wait |
( |
| ) |
|
|
protected |
The documentation for this class was generated from the following file: