digint / digint/tinyfsm

Calling dispatch() and/or transit() from action function

Open
#38 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
1.2k
Forks
193
PR merge metrics
No merged PRs in 30d

Description

In the comment for transit function there is a note: do not send events in action_function definisions.
As I understand, that limitation is bacause of order of operations inside transit() functions:
```
current_state_ptr->exit();
action_function();
current_state_ptr = &_state_instance::value;
current_state_ptr->entry();
```
Any state change caused by action_function() will be overriden by the next line.

What if we rearrange operations so that action is last:
```
current_state_ptr->exit();
current_state_ptr = &_state_instance::value;
current_state_ptr->entry();
action_function();
```
Now we can call all API functions without limitation. Any state change caused by action_function() will count as any other.
What do you think?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.