thread: not joinable?

Hi, I've written my first boost::thread application, and I get this assertion: /boost_1_33_1/libs/thread/src/thread.cpp:223: void boost::thread::join(): Assertion 'm_joinable' failed. I call the thread as: void _pollMode( Controller& ctrl ) { // do polling ... for my testing, left blank } void SomeClass::startPolling() { m_pCtrl = new Controller; boost::function<void (Controller&)> funcPoll; funcPoll = &_pollMode; m_thr = new boost:thread(boost::bind( funcPoll, *m_pCtrl)); // never get past this line (unless copy ctor modified) } The Controller class has a copy constructor defined, which gets called several times (by the thread class?) Controller( const Controller& ctrl ) { boost::mutex::scoped_lock lock( m_mutex ); m_thr = ctrl.m_thr; // bad ?? BUT ... if I do m_thr = NULL; then everything is ok. Why??? What's going on here??? } Any help/explanation would be appreciated. Rob ____________________________________________________________________________________ Sponsored Link Mortgage rates near 39yr lows. $420k for $1,399/mo. Calculate new payment! www.LowerMyBills.com/lre

void SomeClass::startPolling() { m_pCtrl = new Controller; boost::function<void (Controller&)> funcPoll; funcPoll = &_pollMode; m_thr = new boost:thread(boost::bind( funcPoll, *m_pCtrl)); // never get past this line (unless copy ctor modified) }
// snip
Any help/explanation would be appreciated. Rob
Try this instead: void SomeClass::startPolling() { m_pCtrl = new Controller(); m_thr = new boost::thread(boost::bind(&Controller.ThreadFunc, m_pCtrl)); std::cout << "Got here" << std::endl; } Eric
participants (2)
-
Eric Hill
-
Robert Marion