Skip to content

Commit 7d33cef

Browse files
committed
Refactoring
1 parent 0b8f4d1 commit 7d33cef

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
@@ -28,14 +28,14 @@ pthread_mutex_t ThreadPool::mutexWorkCompletion = PTHREAD_MUTEX_INITIALIZER;
2828
ThreadPool::ThreadPool(unsigned int num_thread)
2929
:_num_thread(num_thread)
3030
,_worker_queue(num_thread, NULL)
31-
,queueSize(num_thread)
31+
,_queue_size(num_thread)
3232
{
3333
pthread_mutex_lock(&mutexSync);
3434
_top_index = 0;
3535
_bottom_index = 0;
3636
_incomplete_work = 0;
3737
sem_init(&_available_work, 0, 0);
38-
sem_init(&_available_thread, 0, queueSize);
38+
sem_init(&_available_thread, 0, _queue_size);
3939
pthread_mutex_unlock(&mutexSync);
4040
}
4141

@@ -86,8 +86,8 @@ bool ThreadPool::assignWork(WorkerThread *workerThread)
8686
//workerVec[_top_index] = workerThread;
8787
_worker_queue[_top_index] = workerThread;
8888
//cout << "Assigning Worker[" << workerThread->id << "] Address:[" << workerThread << "] to Queue index [" << _top_index << "]" << endl;
89-
if(queueSize !=1 )
90-
_top_index = (_top_index+1) % (queueSize-1);
89+
if(_queue_size !=1 )
90+
_top_index = (_top_index+1) % (_queue_size-1);
9191
sem_post(&_available_work);
9292
pthread_mutex_unlock(&mutexSync);
9393
return true;
@@ -101,8 +101,8 @@ bool ThreadPool::fetchWork(WorkerThread **workerArg)
101101
WorkerThread * workerThread = _worker_queue[_bottom_index];
102102
_worker_queue[_bottom_index] = NULL;
103103
*workerArg = workerThread;
104-
if(queueSize !=1 )
105-
_bottom_index = (_bottom_index+1) % (queueSize-1);
104+
if(_queue_size !=1 )
105+
_bottom_index = (_bottom_index+1) % (_queue_size-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
@@ -73,7 +73,7 @@ class ThreadPool{
7373
int _incomplete_work;
7474

7575

76-
int queueSize;
76+
int _queue_size;
7777

7878
};
7979

0 commit comments

Comments
 (0)