I have a small shell that centralizes what is relative to threads:
class Thread { protected: boost::thread *m_thread; virtual void work() = 0; void do_work() { work(); } public: Thread() : m_thread(NULL) {} virtual ~Thread() { catch_up(); delete m_thread; } inline void catch_up() { if(m_thread != NULL) { m_thread->join(); } } void run() { m_thread = new boost::thread(boost::bind(&Thread::do_work, boost::ref(*this))); } };
When I implement it, say with the following:
class A : public Thread { void work() {} };
IN:
A a; a.run();
I got a completion with an image of a fairly clean virtual method. I think this is an argument to boost :: bind, but I donβt know how to say "Use virtual clean implementation" ...
Thanks in advance.
Yours faithfully,
Mr mr
c ++ multithreading boost pure-virtual
Mister mystery
source share