Skip to content

Commit 0b8f4d1

Browse files
committed
Refactoring
1 parent 711d1fd commit 0b8f4d1

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

threadpool.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ ThreadPool::ThreadPool(unsigned int num_thread)
3333
pthread_mutex_lock(&mutexSync);
3434
_top_index = 0;
3535
_bottom_index = 0;
36-
incompleteWork = 0;
36+
_incomplete_work = 0;
3737
sem_init(&_available_work, 0, 0);
3838
sem_init(&_available_thread, 0, queueSize);
3939
pthread_mutex_unlock(&mutexSync);
@@ -59,9 +59,9 @@ ThreadPool::~ThreadPool()
5959

6060
void ThreadPool::destroyPool(int maxPollSecs = 2)
6161
{
62-
while( incompleteWork>0 )
62+
while( _incomplete_work>0 )
6363
{
64-
//cout << "Work is still incomplete=" << incompleteWork << endl;
64+
//cout << "Work is still incomplete=" << _incomplete_work << endl;
6565
sleep(maxPollSecs);
6666
}
6767
cout << "All Done!! Wow! That was a lot of work!" << endl;
@@ -76,8 +76,8 @@ void ThreadPool::destroyPool(int maxPollSecs = 2)
7676
bool ThreadPool::assignWork(WorkerThread *workerThread)
7777
{
7878
pthread_mutex_lock(&mutexWorkCompletion);
79-
incompleteWork++;
80-
//cout << "assignWork...incomapleteWork=" << incompleteWork << endl;
79+
_incomplete_work++;
80+
//cout << "assignWork...incomapleteWork=" << _incomplete_work << endl;
8181
pthread_mutex_unlock(&mutexWorkCompletion);
8282

8383
sem_wait(&_available_thread);
@@ -124,7 +124,7 @@ void *ThreadPool::threadExecute(void *param)
124124

125125
pthread_mutex_lock( &(((ThreadPool *)param)->mutexWorkCompletion) );
126126
//cout << "Thread " << pthread_self() << " has completed a Job !" << endl;
127-
((ThreadPool *)param)->incompleteWork--;
127+
((ThreadPool *)param)->_incomplete_work--;
128128
pthread_mutex_unlock( &(((ThreadPool *)param)->mutexWorkCompletion) );
129129
}
130130
return 0;

threadpool.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class ThreadPool{
7070
int _top_index;
7171
int _bottom_index;
7272

73-
int incompleteWork;
73+
int _incomplete_work;
7474

7575

7676
int queueSize;

0 commit comments

Comments
 (0)