[erlang-questions] gen_fsm internal transition

Dmitry Kolesnikov dmkolesnikov@REDACTED
Thu Jan 24 23:38:04 CET 2013


Hello,

In practice, this is a safe way to handle internal transition.
In theory, internal FSM transitions should be avoided.

I would make it like this

state_name0(Event, From, State) ->
   my_action_1(
      my_action_0(State)
   );

state_name1(Event, From State) ->
   my_action1(State);

…
my_action_0(State) ->
   % here goes code from you state_name

my_action_1(State) ->
   % here goes code from your state_name1

- Dmitry



On Jan 24, 2013, at 7:14 PM, Szepes Tamás <tamas@REDACTED> wrote:

> All,
> 
> What is the right way of doing an internal state transition in a gen_fsm?
> 
> Is the following pattern safe to use?
> 
> state_name(Event, From, State) ->
>    .
>    .
>    .
>    gen_fsm:send_event_after(0, internal_transition),
>    {next_state, state_name1, State}.
> 
> state_name1(internal_transition, From, State) ->
>    .
>    .
>    .
>    {reply, ok, state_name1, State}.
> 
> Thanks,
> Tamas
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions




More information about the erlang-questions mailing list