@@ -14,8 +14,9 @@ THREAD_ID TPThread::createThread(void)
1414 &TPThread::threadFunc, (void *)this , NULL , 0 );
1515#else
1616 if (pthread_create (&tidp_, NULL , TPThread::threadFunc,
17- (void *)this )!= 0 )
17+ (void *)this )!= 0 ){
1818 ERROR_MSG (" createThread is error!" );
19+ }
1920#endif
2021 return tidp_;
2122}
@@ -49,9 +50,10 @@ bool ThreadPool::createThreadPool(unsigned int inewThreadCount,
4950 for (unsigned int i=0 ; i<normalThreadCount_; i++)
5051 {
5152 TPThread* tptd = createThread ();
52- if (!tptd)
53+ if (!tptd){
5354 ERROR_MSG (" ThreadPool:: create Thread error! \n " );
54-
55+ }
56+
5557 currentFreeThreadCount_++;
5658 currentThreadCount_++;
5759 freeThreadList_.push_back (tptd); // 闲置的线程列表
@@ -141,11 +143,13 @@ bool ThreadPool::removeHangThread(TPThread* tptd)
141143 itr = find (freeThreadList_.begin (), freeThreadList_.end (), tptd);
142144 itr1 = find (allThreadList_.begin (), allThreadList_.end (), tptd);
143145
144- if (itr != freeThreadList_.end ()&& itr1 != allThreadList_.end ()){
146+ if (itr != freeThreadList_.end ()&& itr1 != allThreadList_.end ())
147+ {
145148 freeThreadList_.erase (itr);
146149 allThreadList_.erase (itr1);
147150 currentThreadCount_--;
148151 currentFreeThreadCount_--;
152+
149153 INFO_MSG (" ThreadPool::removeHangThread: thread.%u is destroy. "
150154 " currentFreeThreadCount:%d, currentThreadCount:%d\n " , \
151155 (unsigned int )tptd->getID (), currentFreeThreadCount_, currentThreadCount_);
@@ -247,7 +251,8 @@ bool TPThread::onWaitCondSignal(void)
247251 threadPool_->removeHangThread (this ); // 通知ThreadPool注销自己
248252 return false ;
249253 }
250- else if (ret != WAIT_OBJECT_0 ){
254+ else if (ret != WAIT_OBJECT_0 )
255+ {
251256 ERROR_MSG (" WaitForSingleObject is error, ret=%d\n " , ret);
252257 }
253258 }
0 commit comments