Skip to content

Commit 711d1fd

Browse files
committed
Refactoring
1 parent 072c228 commit 711d1fd

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

threadpool.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ ThreadPool::ThreadPool(unsigned int num_thread)
3232
{
3333
pthread_mutex_lock(&mutexSync);
3434
_top_index = 0;
35-
bottomIndex = 0;
35+
_bottom_index = 0;
3636
incompleteWork = 0;
3737
sem_init(&_available_work, 0, 0);
3838
sem_init(&_available_thread, 0, queueSize);
@@ -98,11 +98,11 @@ bool ThreadPool::fetchWork(WorkerThread **workerArg)
9898
sem_wait(&_available_work);
9999

100100
pthread_mutex_lock(&mutexSync);
101-
WorkerThread * workerThread = _worker_queue[bottomIndex];
102-
_worker_queue[bottomIndex] = NULL;
101+
WorkerThread * workerThread = _worker_queue[_bottom_index];
102+
_worker_queue[_bottom_index] = NULL;
103103
*workerArg = workerThread;
104104
if(queueSize !=1 )
105-
bottomIndex = (bottomIndex+1) % (queueSize-1);
105+
_bottom_index = (_bottom_index+1) % (queueSize-1);
106106
sem_post(&_available_thread);
107107
pthread_mutex_unlock(&mutexSync);
108108
return true;

threadpool.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class ThreadPool{
6868
std::vector<WorkerThread *> _worker_queue;
6969

7070
int _top_index;
71-
int bottomIndex;
71+
int _bottom_index;
7272

7373
int incompleteWork;
7474

0 commit comments

Comments
 (0)