[erlang-questions] gen_statem next_event queue question

Ingela Andin ingela.andin@REDACTED
Mon Sep 12 12:07:27 CEST 2016


Hi!i!

2016-09-10 6:58 GMT+02:00 Kenneth Lakin <kennethlakin@REDACTED>:

> Okay, I've looked over the gen_statem documentation a few times and have
> not found a way to do what I'm looking to do. Consider the following
> (poorly described) scenario:
>
> My gen_statem is a state_functions gen_statem that's in state 'one'.
> It does some work, and then returns
> {next_state, one, State, [{next_event, internal, e_one}, {next_event,
> internal, e_two}]}
>
> The intent here is that we immediately want to process event e_one, and
> then immediately process event e_two.
>
> So, state 'one' is called again with the event e_one.
> It does some work and determines that it needs to work on e_three after
> the pending event queue is drained. (That is, once e_two has been worked
> on.) If I return
> {next_state, one, State, [{next_event, internal, e_three}]}
> then 'one' will next be called with the event e_three, right?
>
> If that's right, then is there a way to add events to the tail of the
> queue, rather than the head?
>
> Thanks much in advance.
>
>
If you send an event to yourself (gen_statem:call/cast or !) it will end up
last in in the queue. The next_event is to make  sure this event will be
handled next, before other events that may have been received from outside
of the gen_statem processes control during the handling  of the last event.
It is very useful in some cases in others you might not be at all
interested in having internal events.

Regards Ingela Erlang OTP/Team - Ericsson AB





>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160912/25b4caea/attachment.htm>


More information about the erlang-questions mailing list