+ -
+
+ If the state changes or is the initial state, and
+ state enter calls
+ are used, the gen_statem calls
+ the new state callback with arguments
+ (enter, OldState, Data).
+ Any
+ actions
+ returned from this call are handled as if they were
+ appended to the actions
+ returned by the state callback that changed states.
+
+
-
All
@@ -667,37 +681,37 @@ handle_event(_, _, State, Data) ->
are inserted to be processed before the other queued events.
- -
-
- If the state changes or is the initial state, and
- state enter calls
- are used, the gen_statem calls
- the new state callback with arguments
- (enter, OldState, Data).
- Any
- actions
- returned from this call are handled as if they were
- appended to the actions
- returned by the state callback that changed states.
-
-
- -
-
- If there are enqueued events the (possibly new)
- state callback
- is called with the oldest enqueued event,
- and we start again from the top of this list.
-
-
-
Timeout timers
state_timeout()
and
event_timeout()
- are handled. This may lead to a time-out zero event
- being generated to the
+ are handled. Time-outs with zero time are guaranteed to be
+ delivered to the state machine before any external
+ not yet received event so if there is such a timeout requested,
+ the corresponding time-out zero event is enqueued as
+ the newest event.
+
+
+ Any event cancels an
+ event_timeout()
+ so a zero time event time-out is only generated
+ if the event queue is empty.
+
+
+ A state change cancels a
+ state_timeout()
+ and any new transition option of this type
+ belongs to the new state.
+
+
+ -
+
+ If there are enqueued events the
state callback
+ for the possibly new state
+ is called with the oldest enqueued event,
and we start again from the top of this list.
@@ -802,7 +816,7 @@ handle_event(_, _, State, Data) ->
Setting this timer while it is running will restart it with
the new time-out value. Therefore it is possible to cancel
- this timeout by setting it to infinity.
+ this time-out by setting it to infinity.
@@ -1130,7 +1144,7 @@ handle_event(_, _, State, Data) ->
Timeout can also be a tuple
{clean_timeout,T} or
{dirty_timeout,T}, where
- T is the timeout time.
+ T is the time-out time.
{clean_timeout,T} works like
just T described in the note above
and uses a proxy process for T < infinity,
--
cgit v1.2.3
From 32485c0499a0893b4fb69c6e26d91b4303cb1cba Mon Sep 17 00:00:00 2001
From: Raimo Niskanen
Date: Fri, 21 Oct 2016 23:36:26 +0200
Subject: Optimize event timeout
Do not start an event timer unless there are no enqueued events.
---
lib/stdlib/doc/src/gen_statem.xml | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
(limited to 'lib/stdlib/doc/src/gen_statem.xml')
diff --git a/lib/stdlib/doc/src/gen_statem.xml b/lib/stdlib/doc/src/gen_statem.xml
index 567130875a..fd498ee82e 100644
--- a/lib/stdlib/doc/src/gen_statem.xml
+++ b/lib/stdlib/doc/src/gen_statem.xml
@@ -773,8 +773,9 @@ handle_event(_, _, State, Data) ->
after this time (in milliseconds) unless another
event arrives or has arrived
in which case this time-out is cancelled.
- Note that a retried, inserted or state time-out zero
- events counts as arrived.
+ Note that a retried or inserted event counts as arrived.
+ So does a state time-out zero event, if it was generated
+ before this timer is requested.
If the value is infinity, no timer is started, as
--
cgit v1.2.3