diff --git a/src/common/state_machine.hpp b/src/common/state_machine.hpp index 0fa4a3ff7..53a135fbb 100644 --- a/src/common/state_machine.hpp +++ b/src/common/state_machine.hpp @@ -215,9 +215,27 @@ class StateMachineRunner : virtual public EventPoster { return run_queue; } + + void FailIfNonDeferredEventsLeftInEventQueue(queue queue_copy) { + // Check if there are any non-deferred events in the queue - then fail if + while (not queue_copy.empty()) { + EventType event = queue_copy.front(); + queue_copy.pop(); + for (const 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 RunOne() { vector *> run_queue = FillRunQueueFrom(event_queue_); + FailIfNonDeferredEventsLeftInEventQueue(event_queue_); + if (!run_queue.empty()) { for (auto &state : run_queue) { log::Trace("Entering state " + common::BestAvailableTypeName(*state));