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;
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();
}
@ -149,9 +152,7 @@ void Manager::Process()
{
BasicThread* t = *i;
if ( ! t->Killed() )
continue;
if ( t->Killed() )
to_delete.push_back(t);
}