events: Ev1, Ev2. The both are queued to the FMS from the same thread, always in the same order: Ev1, Ev2. The FSM processes them in another thread. The FMS has some "entry" chain of states that defer the both events:
S1 /[defer(Ev1, Ev2)] --> S2 /[defer(Ev1, Ev2)]
and finally 2 orthogonal sub-states, one of them ignores the both events, and the other processes the both:
...S2 --> S3
, S3_1 /[custom_reaction(Ev1), in_state_reaction(Ev2)] What I see is that *sometimes* the reaction for Ev2 is invoked *before* the reaction for Ev1. This "sometimes" really puzzles me: I'm absolutely sure that the order of queuing is always the same - so where can be a "race"?
I think I found out what happened there. If Ev1 and Ev2 are queued one after another quickly enough, they are deferred together through all the chain of states - up to S3_1. BUT if Ev1 already made its way towards the finish when Ev2 is queued, the latter is processed (by deferal or reaction) *first*. And only then the previously deferred Ev1 is processed. Is my guess true? If yes, is there any way to preserve the order of events enqueued to the async machine? Thanks!