diff --git a/utils/threadpool/threadpool.cpp b/utils/threadpool/threadpool.cpp index 0b1546e98..602f868c4 100644 --- a/utils/threadpool/threadpool.cpp +++ b/utils/threadpool/threadpool.cpp @@ -55,6 +55,7 @@ ThreadPool::~ThreadPool() throw() { try { + boost::mutex::scoped_lock initLock(fInitMutex); stop(); } catch (...) @@ -64,6 +65,7 @@ ThreadPool::~ThreadPool() throw() void ThreadPool::init() { + boost::mutex::scoped_lock initLock(fInitMutex); fThreadCount = 0; fGeneralErrors = 0; fFunctorErrors = 0; @@ -89,6 +91,8 @@ void ThreadPool::pruneThread() while(true) { boost::system_time timeout = boost::get_system_time() + boost::posix_time::minutes(1); + if (fStop) + return; if (!fPruneThreadEnd.timed_wait(fPruneMutex, timeout)) { while(!fPruneThreads.empty()) diff --git a/utils/threadpool/threadpool.h b/utils/threadpool/threadpool.h index 1f0c6d0aa..4cb703c07 100644 --- a/utils/threadpool/threadpool.h +++ b/utils/threadpool/threadpool.h @@ -331,8 +331,9 @@ private: uint32_t waitingFunctorsSize; uint64_t fNextHandle; - std::string fName; // Optional to add a name to the pool for debugging. - bool fDebug; + std::string fName; // Optional to add a name to the pool for debugging. + bool fDebug; + boost::mutex fInitMutex; boost::mutex fPruneMutex; boost::condition fPruneThreadEnd; boost::thread* fPruneThread;