boost-ext / sml

C++14 State Machine library
https://boost-ext.github.io/sml
Boost Software License 1.0
1.16k stars 179 forks source link

fix for defer combined with action and multiple defers #592

Closed rvdvvdw closed 1 year ago

rvdvvdw commented 1 year ago

Problem: I believe there are a few problems with the current defer implementation. According to this the defer queue should only be processed when a new state is entered. Currently the defer queue is processed every time an event is handled. This causes problems when the defer is combined with a guard or action.

Solution: I attempted to check the defer queue only after a state change. The check is only performed on the current state of the first region. Therefore it is probably broken for state machines with orthogonal regions.

My solution also break the "defer_reaction" test. If the test accurately describes how the sml::back::defer is supposed to work, then what is the difference with sml::back::process.

Issue: #506 #586

Reviewers: @krzysztof-jusiak