[erlang-questions] gen_fsm - timeout ?

Sanjaya Vitharana sanjaya@REDACTED
Tue Sep 19 10:11:50 CEST 2006


Hi ... ALL,

Behavior: Gen FSM

Scenario:
Want to be in state "open" (see below) for limited time (assume 5 sec) until some EXPECTED event (as_E) comes, have to move to some other state if the expected event not received in that time. All other events should be ignored in state "open".

Problem: Below works fine if no events other than expected comes. But what happend if SOME un-expected events received before timeout? It always keep updating the timeout value to 5000. Removing the timeout value from {next_state, open, State,5000} for "OtherEvents" will cause to stuck in the "open" forever if the expected event not received.

Question: How the time out value should be use in this case ? Are there any way to set the timeout value ONCE for all "OtherEvents".

-------------------------------------------
Asume this as beginning point 

   as(blah,blah), %%Calling Async Func
{next_state, open, State,5000}; 
-------------------------------------------

open(timeout, State) ->
    do_something,
    {next_state, Any_Appropriat, State}.

open(as_E, State) ->
    do_something,
    {next_state, Any_Appropriat, State}.

open(OtherEvents, State) ->
     {next_state, open, State,5000}.

Thanks in advance

Sanjaya Vitharana
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20060919/757ee6cb/attachment.htm>


More information about the erlang-questions mailing list