[erlang-questions] Gen_fsm : race condition with a next_state timeout of zero?

Dmitry Kolesnikov dmkolesnikov@REDACTED
Wed Sep 25 06:15:21 CEST 2013


Hello,

Yes, it is possible. Timeout message is stored to mailbox if there are other messages in mailbox they are evaluated before timeout.

I am doing explicit calls to avoid such issues.
stateA(...) ->
  %% do something
   stateB(myevent

Best Regards,
Dmitry >-|-|-*>


> On 25.9.2013, at 3.23, Andy Gooden <andy.gooden@REDACTED> wrote:
> 
> Hi All, 
> I have a gen_fsm, where upon completing the handling of a message in state_A, I want to immediately transition into state_B... so I have state_A evaluate to:  {next_state, state_B, State, Timeout = 0}.
> 
> In my code, this is the only way to transition into state_B, so I only have implemented:
> state_B ( timeout, State ) -> ...
> 
> Is it possible, if other processes are sending my fsm messages, for me to get a message in my queue while executing state_A code, but then have to handle that message with state_B code?  
> ie  will the immediate transition to state_B via the Timeout = 0 trump any messages that landed in the queue?
> 
> The reason I ask is that I see an error message that looks like state_B is having to handle a message other than 'timeout', even though the only way to get into state_B is from state_A with Timeout = 0.
> 
> Thanks!
> Andy
> 
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions



More information about the erlang-questions mailing list