hekailiang / squirrel

squirrel-foundation is a State Machine library, which provided a lightweight, easy use, type safe and programmable state machine implementation for Java.
http://hekailiang.github.io/squirrel/
Other
2.19k stars 540 forks source link

Event firing has race conditions #129

Open azhuchkov opened 3 years ago

azhuchkov commented 3 years ago

Method AbstractStateMachine.internalFire(...) does current state check before acquiring lock - inside processEvents() which actually has state precheck getStatus() != StateMachineStatus.BUSY which allows to pass through error and terminated states. I suppose that is the reason I've got weird exception that async listener method is not accessible (possible concurrent invocation of terminated event handler).

So, why isIdle() method has this kind of condition? Can it be replaced with getStatus() == StateMachineStatus.IDLE ?