[erlang-questions] FSM: How to wait the end of handle_info ?

Arnaud Garcia arnaud74130@REDACTED
Wed May 9 15:53:50 CEST 2012


Hello everybody,

I have two files, main.erl which control a finite state machine (FSM) with
a gen_fsm behavior.
The FSM is also able to received incoming data from a socket for certain
state (using the handle_info method).

The question is how the main program can wait and know the next state after
handle_info callback is done by the gen_fsm....
because, according to the rawdata received the system move to another state
and main.erl must know this new state to send specifics events....

Maybe more easy to understand with a small illustration

main.erl
   {ok, FSMPid} = myfsm:start_link(...),
    ok =  gen_fsm:sync_send_event(FSMPid, event1)
                  % => will move the FSM to state_5 where we are waiting
socket incoming data
                  % these data will be handle by "handle_info({tcp,
_Socket, RawData}, state_5, StateData)"
                  % depending on the received socket rawdata, we will
change the state of the FSM


       => How can I wait handle_info has finished ?
       => How can I get the state ?
              (for this last question, I think I can just send a
send_all_state(FSMPid, current_state) for example and return the StateName

    program will continue like this:
    case StateName of
         state_13 -> send another event
      ....





thanks for help,

Arnaud
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120509/a8a99774/attachment.htm>


More information about the erlang-questions mailing list