diff --git a/src/common/state_machine.hpp b/src/common/state_machine.hpp index 15dbce29b..78ff58c2f 100644 --- a/src/common/state_machine.hpp +++ b/src/common/state_machine.hpp @@ -223,6 +223,21 @@ class StateMachineRunner : virtual public EventPoster { // actionable until at least one state machine reaches a different state. PostToEventLoop(); } + + // Check if there are any non-deferred events in the queue - then fail if + queue queue_copy = event_queue_; + while (not queue_copy.empty()) { + // If we have no more states, but there is still an event left in the + // queue which is not deferred, then we have a serious logic problem. Panic! + EventType event = queue_copy.front(); + queue_copy.pop(); + for (auto machine : machines_) { + if (machine->deferred_events_.find(event) == machine->deferred_events_.end()) { + log::Fatal( + "The state machine has an unprocessed non-deferred event in the queue. This is a programming error!"); + } + } + } } void PostToEventLoop() {