Skip to content

Commit e7bb9c1

Browse files
committed
timeout needs to be detected once we are sure that t_next will be executed
1 parent 997421c commit e7bb9c1

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

lib/scheduler.cc

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -364,13 +364,6 @@ 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-
374367
// synchronize with physical time if not in fast forward mode
375368
if (!environment_->fast_fwd_execution()) {
376369
log_.debug() << "acquire tag " << t_next << " from physical time barrier";
@@ -402,6 +395,17 @@ void Scheduler::next() { // NOLINT
402395
continue;
403396
}
404397

398+
// Stop execution in case we reach the timeout tag. This checks needs to
399+
// be done here, after acquiring the check, as only then we are fully
400+
// commited to executing the tag t_next. Otherwise, we could still get
401+
// earlier events (e.g., from a physical action).
402+
if (t_next == environment_->timeout_tag()) {
403+
continue_execution_ = false;
404+
log_.debug() << "Shutting down the scheduler due to timeout";
405+
log_.debug() << "Trigger the last round of reactions including all "
406+
"shutdwon reactions";
407+
}
408+
405409
// Retrieve all triggered actions at the next tag.
406410
// We do not need to lock mutex_event_queue_ here, as the lock on
407411
// scheduling_mutex_ already ensures that no one can write to the event

0 commit comments

Comments
 (0)