trigger running transition function before old state exits.
Opened this issue · 1 comments
For example I have 2 states where from state_idle we trigger event to change to state_manual. Trigger is called in function on_state_idle. Monitor log illustrating issue:
- ENTER: state_idle_enter
- EXIT: state_idle_exit
- ENTER: state_manual_enter
- STATE idle after trigger
Here I noticed that trigger function actually calls Fsm::make_transition, witch will call state_idle_exit, and after that state_manual_enter state transition functions.
Problem is that execution continues still in on_state_idle function witch produces my debug printout "STATE idle after trigger". Of course we cannot bail out from on_state_idle, but it would make more sense that transition would occur only when run_machine is called next time, witch would prevent above condition.
Thank you for this awesome library!
To add to this topic I think there should exist both, Asynchronous triggers and synchronous triggers. Pull request I posted ( I'm not exactly C++ coder) is a example solution to allow both with few modifications.
Only thing missing is that there cannot be multiple synchronous triggers triggered in one iteration of run_machine as triggers as only last call will get excecuted.
What is your opinion on solution above?