qmuntal / stateless

Go library for creating finite state machines
BSD 2-Clause "Simplified" License
898 stars 47 forks source link

add Firing() for StateMachine #30

Closed okhowang closed 2 years ago

okhowang commented 2 years ago

close #29

qmuntal commented 2 years ago

Just exposing the firing property is not enough for the general use-case of knowing if an state machine is in firing mode, as it is not set when using FiringImmediate firing mode. If you feel confident enough you can add the required logic (and tests) surrounding this call: https://github.com/qmuntal/stateless/blob/0d59574ef3a12c8d4f833a4ca541e5eef13b3023/statemachine.go#L302-L303

The Firing() method should also be guarded behind firingMutex in case FireCtx is called from different goroutines.