Permalink
Browse files

Applied patch #3015671: ConsumeQueue does not check for empty queue

  • Loading branch information...
1 parent 98260da commit 4a787b8fe28d8b6a038a6b09bf08e40431bda69b Rich Mattes committed Jun 24, 2010
Showing with 13 additions and 11 deletions.
  1. +13 −11 libstage/world.cc
View
24 libstage/world.cc
@@ -552,20 +552,22 @@ void World::ConsumeQueue( unsigned int queue_num )
return;
//printf( "event queue len %d\n", (int)queue.size() );
-
+
// update everything on the event queue that happens at this time or earlier
- Event ev( queue.top() );
- while( ev.time <= sim_time )
+ do
{
- // printf( "@ %llu next event <%s %llu %s>\n", sim_time, ev.TypeStr( ev.type ), ev.time, ev.mod->Token() );
- queue.pop();
-
- if( ev.mod->subs > 0 ) // no subscriptions means the event is discarded
- ev.mod->Update(); // update the model
-
- // and move to the next
- ev = queue.top();
+ Event ev( queue.top() );
+ if( ev.time > sim_time ) break;
+ queue.pop();
+
+ //printf( "@ %llu next event ptr %p\n", sim_time, ev.mod );
+ //std::string modelType = ev.mod->GetModelType();
+ //printf( "@ %llu next event <%s %llu %s>\n", sim_time, modelType.c_str(), ev.time, ev.mod->Token() );
+
+ if( ev.mod->subs > 0 ) // no subscriptions means the event is discarded
+ ev.mod->Update(); // update the model
}
+ while( !queue.empty() );
}
bool World::Update()

0 comments on commit 4a787b8

Please sign in to comment.