You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The behaviour of fsm.terminate() is somewhat unfortunate: it only sets the next state to FINAL but doesn't actually enter that state until the FSM runs again. This means that if any piece of code calls fsm.setNextState() between the fsm.terminate() and the FSM actually terminating (e.g. by reacting to an incoming message, or in an onExit() hook), then the fsm.terminate() is effectively ignored.
I believe an easy way to fix this is to add an fsm.action() immediately after the fsm.terminate(). This way, we both suggest the state transition to the FSM and immediately execute, and therefore this makes sure that no other code can override the state transition. We may want to consider adding this fix to fsm.terminate().
The text was updated successfully, but these errors were encountered:
Terminate should not call action directly. State transitions should occur only on the main thread of the fsm. A simple fix may be to ignore state changes once the next state is marked as FINAL.
State transitions should occur only on the main thread of the fsm.
AFAICT, only agents have threads, not behaviours? So as long you call the fsm.action() on the agent's thread, you should be fine? Having said that, I agree that ignoring state changes out of FINAL should work also.
The behaviour of
fsm.terminate()
is somewhat unfortunate: it only sets the next state toFINAL
but doesn't actually enter that state until the FSM runs again. This means that if any piece of code callsfsm.setNextState()
between thefsm.terminate()
and the FSM actually terminating (e.g. by reacting to an incoming message, or in anonExit()
hook), then thefsm.terminate()
is effectively ignored.I believe an easy way to fix this is to add an
fsm.action()
immediately after thefsm.terminate()
. This way, we both suggest the state transition to the FSM and immediately execute, and therefore this makes sure that no other code can override the state transition. We may want to consider adding this fix tofsm.terminate()
.The text was updated successfully, but these errors were encountered: