42     pthread_cond_init(&
cond, NULL);
 
   44     for (i = 0; i < nThreads; i++) {
 
   58     pthread_cond_signal(&
cond);
 
   71     if (pthread_create(&thread, NULL, 
worker, 
this)) {
 
   91     pthread_cond_signal(&
cond);
 
  157         if (workitem != NULL) {
 
  174     struct timespec interval = {
 
  184         pthread_cond_signal(&
cond);
 
  185         nanosleep(&interval, NULL);
 
  191     pthread_cond_destroy(&
cond);
 
Implements the thread pool pattern. 
 
pthread_mutex_t mutexThread
 
static pthread_t thread
thread. 
 
void *(* workRoutine)(void *)
 
static void * worker(void *)
Working thread. 
 
pthread_mutex_t mutexWorker
 
pthread_mutex_t mutexWorkItem
 
ThreadPool(int nThreads, void *(*workRoutine)(void *))
Creates a new thread pool. 
 
virtual ~ThreadPool()
Deletes thread pool. 
 
std::deque< void * > worklist
 
Implements the thread pool pattern. 
 
int isStopping()
Is thread pool stopping. 
 
long getWorklistSize()
Gets size of worklist. 
 
void exitThread(void *retval)
Exits a worker thread. 
 
void * getWorkItem()
Gets a work item. 
 
int createThread()
Creates a new worker thread. 
 
void add(void *workItem)
Adds a work item to the work list.