@@ -91,17 +91,17 @@ void Scheduler::schedule() noexcept {
9191 bool found_ready_reactions = schedule_ready_reactions ();
9292
9393 while (!found_ready_reactions) {
94- log_.debug () << " call next()" ;
95- next ();
96- reaction_queue_pos_ = 0 ;
97-
98- found_ready_reactions = schedule_ready_reactions ();
99-
10094 if (!continue_execution_ && !found_ready_reactions) {
10195 // let all workers know that they should terminate
10296 terminate_all_workers ();
10397 break ;
10498 }
99+
100+ log_.debug () << " call next()" ;
101+ next ();
102+ reaction_queue_pos_ = 0 ;
103+
104+ found_ready_reactions = schedule_ready_reactions ();
105105 }
106106}
107107
@@ -354,8 +354,8 @@ void Scheduler::next() { // NOLINT
354354 log_.debug () << " Shutting down the scheduler" ;
355355 Tag t_next = Tag::from_logical_time (logical_time_).delay ();
356356 if (!event_queue_.empty () && t_next == event_queue_.next_tag ()) {
357- log_.debug () << " Schedule the last round of reactions including all "
358- " termination reactions" ;
357+ log_.debug () << " Trigger the last round of reactions including all "
358+ " shutdown reactions" ;
359359 triggered_actions_ = event_queue_.extract_next_event ();
360360 advance_logical_time_to (t_next);
361361 } else {
@@ -364,6 +364,13 @@ void Scheduler::next() { // NOLINT
364364 } else {
365365 auto t_next = event_queue_.next_tag ();
366366
367+ if (t_next == environment_->timeout_tag ()) {
368+ continue_execution_ = false ;
369+ log_.debug () << " Shutting down the scheduler due to timeout" ;
370+ log_.debug () << " Trigger the last round of reactions including all "
371+ " shutdwon reactions" ;
372+ }
373+
367374 // synchronize with physical time if not in fast forward mode
368375 if (!environment_->fast_fwd_execution ()) {
369376 log_.debug () << " acquire tag " << t_next << " from physical time barrier" ;
0 commit comments