|
Boost Users : |
From: xargon (pankaj.daga_at_[hidden])
Date: 2006-02-06 15:28:49
Hi everyone,
I am trying to use the boost multithreading library. I am having a
problem as the join() function for the thread never returns. I am using
a boolean variable to indicate when the thread should stop running.
Here is basically a stub of what I am doing:
//........................................
bool m_RunThread = false;
scoped_ptr myThread;
//.......................................
void MyObject::StartThread()
{
m_RunThread = true;
myThread.reset(new boost::thread(boost::bind
(&MyObject::MyThreadFunc, this)));
}
void MyObject::StopThread()
{
m_RunThread = false;
myThread.join(); // this function never returns!
... Never gets here....
}
void MyObject::MyThreadFunc()
{
while (m_RunThread)
{
// do something
}
}
However, the join() function in StopThread never returns. I think that
using a variable to synchronize this is probably not a good idea. Any
thoughts and suggestions?
Cheers,
K
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net