18 #ifndef itkThreadPool_h
19 #define itkThreadPool_h
21 #include "itkConfigure.h"
26 #if defined(ITK_USE_PTHREADS)
28 #include <semaphore.h>
30 #elif defined(ITK_USE_WIN32_THREADS)
35 #include <mach/mach_init.h>
36 #include <mach/mach_error.h>
37 #include <mach/semaphore.h>
38 #include <mach/task.h>
39 #include <mach/task_info.h>
116 #if defined(__APPLE__)
117 semaphore_t m_Semaphore;
118 #elif defined(_WIN32) || defined(_WIN64)
120 #elif defined(ITK_USE_PTHREADS)
136 ITK_DISALLOW_COPY_AND_ASSIGN(ThreadPool);
139 bool m_ScheduleForDestruction;
148 unsigned int m_IdCounter;
151 bool m_ExceptionOccurred;
166 ThreadJobContainerType m_WorkerQueue;
172 ThreadProcessIdContainerType m_ThreadHandles;
177 JOB_THREADHANDLE_JUST_ADDED=-3,
178 JOB_THREADHANDLE_IS_FREE=-2,
180 JOB_THREADHANDLE_IS_DONE=-1
197 #if defined(ITK_USE_WIN32_THREADS)
205 m_ThreadNumericId(tnid),
206 m_ThreadProcessHandle(tph),
207 m_WinThreadId(winThreadId)
225 ThreadProcessIdentifiersVecType m_ThreadProcessIdentifiersVector;
230 ThreadSemHandlePairingQueueType m_ThreadSemHandlePairingQueue;
231 ThreadSemHandlePairingQueueType m_ThreadSemHandlePairingForWaitQueue;
267 ThreadSemaphorePair* GetSemaphore(ThreadSemHandlePairingQueueType &q,ThreadProcessIdType threadHandle);
273 void DeallocateThreadSemSet(ThreadSemHandlePairingQueueType &q);
276 static
void * ThreadExecute(
void *param);
279 static
bool CompareThreadHandles(ThreadProcessIdType t1, ThreadProcessIdType t2);
282 ThreadProcessIdType GetThreadHandleForThreadId(
ThreadIdType id);
std::pair< ThreadJobIdType, ThreadJob > ThreadJobContainerPairType
Critical section locking class that can be allocated on the stack.
std::vector< ThreadProcessIdentifiers > ThreadProcessIdentifiersVecType
This class is used to submit jobs to the thread pool. The thread job maintains important information ...
SmartPointer< Self > Pointer
ThreadJob::JobIdType ThreadJobIdType
std::map< ThreadJobIdType, ThreadJob > ThreadJobContainerType
std::set< ThreadJobIdType > ThreadJobIdsContainerType
std::vector< ThreadSemaphorePair * > ThreadSemHandlePairingQueueType
static int m_SemaphoreCount
ThreadProcessIdType m_ThreadProcessHandle
SmartPointer< const Self > ConstPointer
std::set< ThreadProcessIdType > ThreadProcessIdContainerType
unsigned long WinThreadIdType
ThreadProcessIdentifiers(const int tnid, const ThreadProcessIdType tph, const WinThreadIdType winThreadId)
unsigned int ThreadIdType
Thread pool manages the threads for itk.
unsigned int ThreadCountType
WinThreadIdType m_WinThreadId
Base class for most ITK classes.
ThreadProcessIdType m_ThreadProcessHandle