|
OGR
|
#include <cpl_worker_thread_pool.h>
Public Member Functions | |
| CPLWorkerThreadPool () | |
| ~CPLWorkerThreadPool () | |
| bool | Setup (int nThreads, CPLThreadFunc pfnInitFunc, void **pasInitData) |
| bool | Setup (int nThreads, CPLThreadFunc pfnInitFunc, void **pasInitData, bool bWaitallStarted) |
| bool | SubmitJob (CPLThreadFunc pfnFunc, void *pData) |
| bool | SubmitJobs (CPLThreadFunc pfnFunc, const std::vector< void *> &apData) |
| void | WaitCompletion (int nMaxRemainingJobs=0) |
| void | WaitEvent () |
| int | GetThreadCount () const |
Pool of worker threads
| CPLWorkerThreadPool::CPLWorkerThreadPool | ( | ) |
Instantiate a new pool of worker threads.
The pool is in an uninitialized state after this call. The Setup() method must be called.
| CPLWorkerThreadPool::~CPLWorkerThreadPool | ( | ) |
Destroys a pool of worker threads.
Any still pending job will be completed before the destructor returns.
References CPLListDestroy(), and WaitCompletion().
|
inline |
Return the number of threads setup
| bool CPLWorkerThreadPool::Setup | ( | int | nThreads, |
| CPLThreadFunc | pfnInitFunc, | ||
| void ** | pasInitData | ||
| ) |
Setup the pool.
| nThreads | Number of threads to launch |
| pfnInitFunc | Initialization function to run in each thread. May be NULL |
| pasInitData | Array of initialization data. Its length must be nThreads, or it should be NULL. |
| bool CPLWorkerThreadPool::Setup | ( | int | nThreads, |
| CPLThreadFunc | pfnInitFunc, | ||
| void ** | pasInitData, | ||
| bool | bWaitallStarted | ||
| ) |
Setup the pool.
| nThreads | Number of threads to launch |
| pfnInitFunc | Initialization function to run in each thread. May be NULL |
| pasInitData | Array of initialization data. Its length must be nThreads, or it should be NULL. |
| bWaitallStarted | Whether to wait for all threads to be fully started. |
References CPLAssert.
| bool CPLWorkerThreadPool::SubmitJob | ( | CPLThreadFunc | pfnFunc, |
| void * | pData | ||
| ) |
Queue a new job.
| pfnFunc | Function to run for the job. |
| pData | User data to pass to the job function. |
References CPLAssert, CPLDebug(), CPLFree, _CPLList::pData, _CPLList::psNext, VSI_MALLOC_VERBOSE, and VSIFree().
| bool CPLWorkerThreadPool::SubmitJobs | ( | CPLThreadFunc | pfnFunc, |
| const std::vector< void *> & | apData | ||
| ) |
Queue several jobs
| pfnFunc | Function to run for the job. |
| apData | User data instances to pass to the job function. |
References CPLAssert, CPLDebug(), CPLFree, _CPLList::pData, _CPLList::psNext, VSI_MALLOC_VERBOSE, and VSIFree().
| void CPLWorkerThreadPool::WaitCompletion | ( | int | nMaxRemainingJobs = 0 | ) |
Wait for completion of part or whole jobs.
| nMaxRemainingJobs | Maximum number of pendings jobs that are allowed in the queue after this method has completed. Might be 0 to wait for all jobs. |
Referenced by ~CPLWorkerThreadPool().
| void CPLWorkerThreadPool::WaitEvent | ( | ) |
Wait for completion of at least one job, if there are any remaining
1.8.14.