Parallel State Transitions #42
-
I can't tell from the wiki how transitions are fired for parallel states. If the machine is "in" multiple parallel states and they all have transitions that match an event, are they all fired? If so, in what order? Sequentially or multithreaded? I think my project has a use case for parallel states but it depends on the above. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
As I see from test case "process event by parallel states negative", multiple transitions for one event is currently not possible. Exception will be thrown in this case. The rule of firing neighbour notifications in all the library: such notifications are fired sequentially, without multithreading, execution order is not specified, you should not rely on it. |
Beta Was this translation helpful? Give feedback.
-
Fair enough. I'll have a play around and see what is possible. |
Beta Was this translation helpful? Give feedback.
-
I am writing a snooker scoreboard app.
In snooker, if the game is in the state "on a red" and also the state "free
ball" then the event "pot red" adds 1 to the score but doesn't decrease the
remaining reds count. If it is not a free ball then the remaining red count
is decremented.
You can also be in a "free ball" state when in the "on a colour" state.
Hence why I am considering parallel states.
In essence, there are small semantic side effect differences for some
transitions when in a free ball situation. All other transitions remain
unaffected.
I could, of course, simply keep "free ballness" as a class variable but
prefer the cleanliness of using StateMachine.
I prefer to use parallel states, keeping the transition side effects in the
master "on a red" state, but with some logic that tests whether the free
ball state is active or not, to adjust the side effects.
Now I think about it, it's also unclear to me how the machine would exit
the free ball state. Are all parallel states exited when any of them exit?
…On Tue, 26 Jul 2022, 06:16 Mikhail Fedotov, ***@***.***> wrote:
How do you want to use multiple transitions in parallel states?
Current limitation takes place, as those transitions may affect each other
by changing machine in conflicting way.
Looks that the only case when it may work when all such transitions are
targeted to states that are deeper children of "parallel" layer state.
—
Reply to this email directly, view it on GitHub
<#42 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/APZQI42QSP5ERXF6HQT6Y2TVV5YELANCNFSM54UPKYPQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
As I see from test case "process event by parallel states negative", multiple transitions for one event is currently not possible. Exception will be thrown in this case.
The rule of firing neighbour notifications in all the library: such notifications are fired sequentially, without multithreading, execution order is not specified, you should not rely on it.