Question

I want my FSM to terminate any time event doesn't come after specified amout of time in every state.

I can achieve such a scenario only in case there is no event after FSM creation by specifing timeout value in init callback, but I would like to have this functionality working for all of the states as well.

Any easy & quick solution?

Best Regards

Matt

Was it helpful?

Solution

You can set timeout in return tuple in each state {next_state, NextStateName, NewStateData, Timeout}. See gen_fsm documentation for more details. But it works only for case there is not any incoming messages in gen_fsm so it is suitable only if for example you would like terminate process when probably nobody is communicating with it. If you would like hard limits (for protocols for example) you should use erlang:send_after/3 or erlang:start_timer/3 and handle also timer termination and so.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top