18 #if defined(_WIN32)||defined(WIN32)||defined(__WIN32__)
19 #define DRWN_USE_WIN32THREADS
21 #define DRWN_USE_PTHREADS
24 #ifdef DRWN_USE_PTHREADS
28 #ifdef DRWN_USE_WIN32THREADS
58 virtual void operator()() = 0;
64 inline unsigned threadId() {
return _threadId; }
94 void finish(
bool bShowStatus =
false);
99 unsigned numJobsRemaining();
103 #ifdef DRWN_USE_PTHREADS
104 static void *runJobs(
void *argPtr);
106 #ifdef DRWN_USE_WIN32THREADS
107 static unsigned __stdcall runJobs(
void *argPtr);
110 #if defined(DRWN_USE_PTHREADS)||defined(DRWN_USE_WIN32THREADS)
111 struct drwnThreadArgs {
117 queue<drwnThreadJob *> _jobQ;
121 #ifdef DRWN_USE_PTHREADS
123 drwnThreadArgs *_args;
125 pthread_mutex_t _mutex;
126 pthread_cond_t _cond;
128 #ifdef DRWN_USE_WIN32THREADS
130 drwnThreadArgs *_args;
132 CRITICAL_SECTION _mutex;
133 CONDITION_VARIABLE _cond;
138 bool _bProfilerEnabled;
Implements a pool of threads for running concurrent jobs.
Definition: drwnThreadPool.h:76
Interface for a thread job functor.
Definition: drwnThreadPool.h:45
static unsigned MAX_THREADS
maximum number of threads allowed
Definition: drwnThreadPool.h:80
unsigned threadId()
obtain the id for the thread running (or that ran) this job. The return value is guaranteed to be bet...
Definition: drwnThreadPool.h:64
unsigned numThreads() const
return the number of threads running
Definition: drwnThreadPool.h:97