@@ -35,7 +35,7 @@ ThreadPool::ThreadPool(unsigned int num_thread)
3535 bottomIndex = 0 ;
3636 incompleteWork = 0 ;
3737 sem_init (&_available_work, 0 , 0 );
38- sem_init (&availableThreads , 0 , queueSize);
38+ sem_init (&_available_thread , 0 , queueSize);
3939 pthread_mutex_unlock (&mutexSync);
4040}
4141
@@ -66,7 +66,7 @@ void ThreadPool::destroyPool(int maxPollSecs = 2)
6666 }
6767 cout << " All Done!! Wow! That was a lot of work!" << endl;
6868 sem_destroy (&_available_work);
69- sem_destroy (&availableThreads );
69+ sem_destroy (&_available_thread );
7070 pthread_mutex_destroy (&mutexSync);
7171 pthread_mutex_destroy (&mutexWorkCompletion);
7272
@@ -80,7 +80,7 @@ bool ThreadPool::assignWork(WorkerThread *workerThread)
8080 // cout << "assignWork...incomapleteWork=" << incompleteWork << endl;
8181 pthread_mutex_unlock (&mutexWorkCompletion);
8282
83- sem_wait (&availableThreads );
83+ sem_wait (&_available_thread );
8484
8585 pthread_mutex_lock (&mutexSync);
8686 // workerVec[topIndex] = workerThread;
@@ -103,7 +103,7 @@ bool ThreadPool::fetchWork(WorkerThread **workerArg)
103103 *workerArg = workerThread;
104104 if (queueSize !=1 )
105105 bottomIndex = (bottomIndex+1 ) % (queueSize-1 );
106- sem_post (&availableThreads );
106+ sem_post (&_available_thread );
107107 pthread_mutex_unlock (&mutexSync);
108108 return true ;
109109}
0 commit comments