From 447f3cf2d041670d93683de4fab02338b26fbaf1 Mon Sep 17 00:00:00 2001 From: Raimo Niskanen Date: Thu, 3 Mar 2016 11:27:02 +0100 Subject: Rename state_timeout -> event_timeout --- lib/stdlib/doc/src/gen_statem.xml | 36 +++++++++++++++++++++++------------- lib/stdlib/src/gen_statem.erl | 10 +++++----- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/lib/stdlib/doc/src/gen_statem.xml b/lib/stdlib/doc/src/gen_statem.xml index db6a4e03ea..4489ddfb91 100644 --- a/lib/stdlib/doc/src/gen_statem.xml +++ b/lib/stdlib/doc/src/gen_statem.xml @@ -155,7 +155,7 @@ erlang:'!' -----> Module:StateName/3

Inserting an event replaces the trick of calling your own state handling functions that you often would have to - resort to in e.g gen_fsm + resort to in for example gen_fsm to force processing an inserted event before others. If you for example in gen_statem postpone an event in one state and then call some other state function of yours, @@ -529,17 +529,16 @@ ok all other events. - If a - - state_timeout() + If an + + event_timeout() is set through action() timeout - a state timer may be started or a timeout zero event - may be enqueued as the newest incoming, that is the last - to process before going into receive for new events. + an event timer may be started or a timeout zero event + may be enqueued. The (possibly new) @@ -588,7 +587,7 @@ ok - +

Generate an event of @@ -600,7 +599,8 @@ ok If the value is infinity no timer is started. If it is 0 the timeout event is immediately enqueued as the newest received - (unless there are retried or inserted events to process). + (unless there are retried or inserted events to process + since then the timeout is cancelled). Also note that it is not possible nor needed to cancel this timeout since it is cancelled automatically by any other event. @@ -653,15 +653,25 @@ ok for this state transition. + Timeout + + Short for {timeout,Timeout} that is + the timeout message is the timeout time. + This form exists to make the + state function + return value {next_state,NextState,NewData,Timeout} + allowed like for + + gen_fsm Module:StateName/2. + timeout Set the - transition_option() state_timeout() + transition_option() event_timeout() to Time with the - EventContent as Msg - for the next state. + EventContent as Msg. reply_action() Reply to a caller. @@ -1419,7 +1429,7 @@ ok

This function is called by a gen_statem when it should update its internal state during a release upgrade/downgrade, - i.e. when the instruction {update,Module,Change,...} + that is when the instruction {update,Module,Change,...} where Change={advanced,Extra} is given in the appup file. See diff --git a/lib/stdlib/src/gen_statem.erl b/lib/stdlib/src/gen_statem.erl index 438c366f8e..92e26bd7ed 100644 --- a/lib/stdlib/src/gen_statem.erl +++ b/lib/stdlib/src/gen_statem.erl @@ -77,7 +77,7 @@ -type callback_mode() :: 'state_functions' | 'handle_event_function'. -type transition_option() :: - postpone() | hibernate() | state_timeout(). + postpone() | hibernate() | event_timeout(). -type postpone() :: %% If 'true' postpone the current event %% and retry it when the state changes (=/=) @@ -85,7 +85,7 @@ -type hibernate() :: %% If 'true' hibernate the server instead of going into receive boolean(). --type state_timeout() :: +-type event_timeout() :: %% Generate a ('timeout', Msg, ...) event after Time %% unless some other event is delivered Time :: timeout(). @@ -111,9 +111,9 @@ 'hibernate' | % Set the hibernate option {'hibernate', Hibernate :: hibernate()} | %% - (Timeout :: state_timeout()) | % {timeout,Timeout} - {'timeout', % Set the timeout option - Time :: state_timeout(), Msg :: term()} | + (Timeout :: event_timeout()) | % {timeout,Timeout} + {'timeout', % Set the event timeout option + Time :: event_timeout(), Msg :: term()} | %% reply_action() | %% -- cgit v1.2.3