Skip to content

Event Deferring

Sergei Fedorov edited this page Nov 20, 2016 · 1 revision

Any state or a state machine can declare that it 'defers' an event. That means that the state cannot handle the event straight away, but the event should be saved for processing later, by a state that can handle it. To achieve it, a state or a state machine should define data type deferred_events that is a type alias for a ::psst::meta::type_tuple variadic template containing event types. There is type_tuple type alias inside ::afsm::def::state and ::afsm::def::state_machine templates.

struct my_state : state<my_state> {
    using deferred_events = type_tuple< event_a, event_b >;
};

Deferred events will be stored by the outermost state machine in deferred queue and they will be checked for processing after each state transition (event handled without a state transition won't provide conditions to process the events). The events will be copied to the event queue. Move construction will be used if applicable.

Clone this wiki locally