: m_ID(m_NextID++), m_MaxItems(maxItems), m_Stopped(false),
m_Processing(false), m_ExceptionCallback(WorkQueue::DefaultExceptionCallback)
{
- m_Thread = boost::thread(boost::bind(&WorkQueue::WorkerThreadProc, this));
-
m_StatusTimer = make_shared<Timer>();
m_StatusTimer->SetInterval(10);
m_StatusTimer->OnTimerExpired.connect(boost::bind(&WorkQueue::StatusTimerHandler, this));
boost::mutex::scoped_lock lock(m_Mutex);
+ if (m_Thread.get_id() == boost::thread::id())
+ m_Thread = boost::thread(boost::bind(&WorkQueue::WorkerThreadProc, this));
+
if (!wq_thread) {
while (m_Items.size() >= m_MaxItems)
m_CVFull.wait(lock);
m_CVEmpty.notify_all();
lock.unlock();
- m_Thread.join();
+ if (m_Thread.joinable())
+ m_Thread.join();
}
}