
I'm trying to set several threads running and have the main thread
signal an interrupt. I've included an example that shows what I'm
trying to accomplish. The threads that are created are associated with
thread_group and then a join_all is called. I would expect the main
thread to be able to call interrupt_all on the thread_group. Since this
wasn't working I looked at what the join_all and interrupt_all function
were actually doing. It turns out that thread_group has a mutex that is
being called for each function and since the mutex for join_all is in
use, the lock in interrupt_all is blocking. I understand why the mutex
is there but am unclear how interrupt_all is suppose to work with
join_all. To accomplish the functionality I need I have to use
create_thread and store the return pointer in a list of my own. Then
call interrupt on each pointer I stored. Which is basically duplicating
the storage of thread_group. This seem like a waste. I would
appreciate any advice.
Ryan
class Converter
{
public:
Converter(void) {
m_Threads.reset(new boost::thread_group);
}
void run(void) {
m_Threads->add_thread(new
boost::thread(boost::bind(&Converter::processSureTrakMessage, this)));
//m_Threads_v.push_back(m_Threads->create_thread(boost::bind(&Converter::processSureTrakMessage,
this)));
m_Threads->join_all();
m_Threads.reset(new boost::thread_group);
}
void stop(void) {
//for (std::vector