From a2f3c685b5aeac798e12302cf8fe7df13184b669 Mon Sep 17 00:00:00 2001 From: Raimo Niskanen Date: Fri, 15 Apr 2016 10:09:54 +0200 Subject: Introduce corrections from Fred Hebert and Ingela --- system/doc/design_principles/statem.xml | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'system/doc') diff --git a/system/doc/design_principles/statem.xml b/system/doc/design_principles/statem.xml index 65daeac782..02754bd23d 100644 --- a/system/doc/design_principles/statem.xml +++ b/system/doc/design_principles/statem.xml @@ -90,7 +90,7 @@ State(S) x Event(E) -> Actions(A), State(S')
 StateName(EventType, EventContent, Data) ->
     .. code for actions here ...
-    {next_state, StateName', Data'}.
+ {next_state, NewStateName, NewData}.

In the mode handle_event_function there is only one Erlang function that implements all state transition rules: @@ -612,7 +612,7 @@ stop() -> An example of event postponing comes in later in this chapter. See the - documentation + reference manual for details. You can for example actually reply to several callers and generate multiple next events to handle. @@ -735,7 +735,8 @@ open(cast, {button,_}, Data) -> erlang:cancel_timer(Tref). Note that a timeout message can not arrive after this, - unless you have postponed it before (why on earth one would do that). + unless you have postponed it (see the next section) before, + so make sure you do not accidentally postpone such messages.

Another way to cancel a timer is to not cancel it, @@ -837,15 +838,25 @@ do_unlock() -> The selective receive in this case causes open to implicitly postpone any events to the locked state.

+

+ A selective receive can not be used from a gen_statem + behaviour just as for any gen_* behavior + since the receive statement is within the gen_* engine itself. + It has to be there because all + sys + compatible behaviours must respond to system messages and therefore + do that in their engine receive loop, + passing non-system messages to the callback module. +

The state transition action postpone is designed to be able to model - selective receive. Selective receive implicitly postpones + selective receives. A selective receive implicitly postpones any not received events, but the postpone - state transition action explicitly postpones a received event. + state transition action explicitly postpones one received event.

Other than that both mechanisms have got the same theoretical -- cgit v1.2.3