Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trigger running transition function before old state exits. #20

Open
Troyhy opened this issue Dec 1, 2017 · 1 comment
Open

trigger running transition function before old state exits. #20

Troyhy opened this issue Dec 1, 2017 · 1 comment

Comments

@Troyhy
Copy link

Troyhy commented Dec 1, 2017

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:

  1. ENTER: state_idle_enter
  2. EXIT: state_idle_exit
  3. ENTER: state_manual_enter
  4. 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!

@Troyhy
Copy link
Author

Troyhy commented Dec 2, 2017

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant