30 #ifndef CPL_WORKER_THREAD_POOL_H_INCLUDED_ 31 #define CPL_WORKER_THREAD_POOL_H_INCLUDED_ 33 #include "cpl_multiproc.h" 49 CPLThreadFunc pfnFunc;
55 CPLThreadFunc pfnInitFunc;
58 CPLJoinableThread *hThread;
71 } CPLWorkerThreadState;
72 #endif // ndef DOXYGEN_SKIP 79 std::vector<CPLWorkerThread> aWT{};
80 CPLCond* hCond =
nullptr;
81 CPLMutex* hMutex =
nullptr;
82 volatile CPLWorkerThreadState eState = CPLWTS_OK;
84 volatile int nPendingJobs = 0;
86 CPLList* psWaitingWorkerThreadsList =
nullptr;
87 int nWaitingWorkerThreads = 0;
89 static void WorkerThreadFunction(
void* user_data);
91 void DeclareJobFinished();
92 CPLWorkerThreadJob* GetNextJob(CPLWorkerThread* psWorkerThread);
98 bool Setup(
int nThreads,
99 CPLThreadFunc pfnInitFunc,
101 bool Setup(
int nThreads,
102 CPLThreadFunc pfnInitFunc,
104 bool bWaitallStarted);
105 bool SubmitJob(CPLThreadFunc pfnFunc,
void* pData);
106 bool SubmitJobs(CPLThreadFunc pfnFunc,
const std::vector<void*>& apData);
107 void WaitCompletion(
int nMaxRemainingJobs = 0);
114 #endif // CPL_WORKER_THREAD_POOL_H_INCLUDED_ List element structure.
Definition: cpl_list.h:51
int GetThreadCount() const
Return the number of threads setup.
Definition: cpl_worker_thread_pool.h:111
Simplest list implementation.
Pool of worker threads.
Definition: cpl_worker_thread_pool.h:75
#define CPL_DISALLOW_COPY_ASSIGN(ClassName)
Helper to remove the copy and assignment constructors so that the compiler will not generate the defa...
Definition: cpl_port.h:989