diff --git a/utils/threadpool/threadpool.cpp b/utils/threadpool/threadpool.cpp index a12e574b8..589fb6dcc 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 7bc605472..84c9aff7a 100644 --- a/utils/threadpool/threadpool.h +++ b/utils/threadpool/threadpool.h @@ -357,6 +357,7 @@ private: 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;