Fix thread processing/termination conditions.

A thread that is done/killed should signify that the thread manager has
some processing to do -- it needs to process any messages in its out
queue, join the thread, and delete it.  Otherwise the thread manager
may reach a state where it makes no progress in processing the last
remaining done/killed thread.
This commit is contained in:
Jon Siwek 2013-10-29 14:40:07 -05:00
parent 26be082951
commit 22d35d2c8c

View file

@ -82,7 +82,10 @@ double Manager::NextTimestamp(double* network_time)
{ {
MsgThread* t = *i; MsgThread* t = *i;
if ( (*i)->MightHaveOut() && ! t->Killed() ) if ( t->MightHaveOut() || t->Killed() )
// Even if the thread doesn't have output, it may be killed/done,
// which should also signify that processing is needed. The
// "processing" in that case is joining the thread and deleting it.
return timer_mgr->Time(); return timer_mgr->Time();
} }
@ -149,10 +152,8 @@ void Manager::Process()
{ {
BasicThread* t = *i; BasicThread* t = *i;
if ( ! t->Killed() ) if ( t->Killed() )
continue; to_delete.push_back(t);
to_delete.push_back(t);
} }
for ( all_thread_list::iterator i = to_delete.begin(); i != to_delete.end(); i++ ) for ( all_thread_list::iterator i = to_delete.begin(); i != to_delete.end(); i++ )