Skip to content

Commit 6c06d5a

Browse files
committed
check for an empty event queue in every iteration of the loop
1 parent 7affc88 commit 6c06d5a

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

lib/scheduler.cc

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -254,18 +254,19 @@ void Scheduler::next() { // NOLINT
254254
{
255255
std::unique_lock<std::mutex> lock{scheduling_mutex_};
256256

257-
// shutdown if there are no more events in the queue
258-
if (event_queue_.empty() && !stop_) {
259-
if (environment_->run_forever()) {
260-
// wait for a new asynchronous event
261-
cv_schedule_.wait(lock, [this]() { return !event_queue_.empty() || stop_; });
262-
} else {
263-
log_.debug() << "No more events in queue_. -> Terminate!";
264-
environment_->sync_shutdown();
257+
while (triggered_actions_ == nullptr || triggered_actions_->empty()) {
258+
259+
// shutdown if there are no more events in the queue
260+
if (event_queue_.empty() && !stop_) {
261+
if (environment_->run_forever()) {
262+
// wait for a new asynchronous event
263+
cv_schedule_.wait(lock, [this]() { return !event_queue_.empty() || stop_; });
264+
} else {
265+
log_.debug() << "No more events in queue_. -> Terminate!";
266+
environment_->sync_shutdown();
267+
}
265268
}
266-
}
267269

268-
while (triggered_actions_ == nullptr || triggered_actions_->empty()) {
269270
if (triggered_actions_ != nullptr) {
270271
action_list_pool_.emplace_back(std::move(triggered_actions_));
271272
}

0 commit comments

Comments
 (0)