qmuntal / stateless

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

State machine will not change if OnEntry() took long time to execute #6

Closed luxl closed 4 years ago

luxl commented 4 years ago

I have a state "A" which has OnEntry() function, in this function, it will sleep 5s. During the sleeping time, another goroutine tries to fire another trigger to change the state, but the state will not change and no error happened. Is this normal? Or can I do long-time operations in the OnEntry() function

luxl commented 4 years ago

I found the reason, I should use ''NewStateMachineWithMode" and pass "FiringImmediate" as the parameter, closing now