
2009/7/29 Craig Henderson
class WorkerThread { public: typedef boost::function
JobType; WorkerThread() { m_Thread = boost::thread(boost::bind(&WorkerThread::run, boost::ref(this))); }
~WorkerThread() { while (!m_Running) ; m_Thread.join(); m_Running = false; }
const bool isRunning() const { return m_Running; }
private: volatile bool m_Running; boost::thread m_Thread;
void run() { m_Running = true; BOOST_ASSERT(isRunning()); }
private: WorkerThread(const WorkerThread& rhs); WorkerThread& operator = (const WorkerThread& rhs); };
Regards -- Craig
You need to initial m_Running=false; in the ctor, too. -- Craig