From d86fd35ca0c65069955a34d6ae9fbc33b9663eb0 Mon Sep 17 00:00:00 2001 From: Raimo Niskanen Date: Tue, 20 Mar 2018 03:34:23 -0700 Subject: Update User's Guide and pointers to it --- lib/stdlib/doc/src/gen_statem.xml | 89 +++++++++++++++++++++++++++------------ 1 file changed, 62 insertions(+), 27 deletions(-) (limited to 'lib') diff --git a/lib/stdlib/doc/src/gen_statem.xml b/lib/stdlib/doc/src/gen_statem.xml index be0d64feba..252a8370ad 100644 --- a/lib/stdlib/doc/src/gen_statem.xml +++ b/lib/stdlib/doc/src/gen_statem.xml @@ -32,39 +32,43 @@ Generic state machine behavior.

- This behavior module provides a state machine. Two - callback modes - are supported: + gen_statem provides a generic state machine behaviour + and replaces its predecessor + gen_fsm + since Erlang/OTP 20.0. +

+

+ This reference manual describes types generated from the types + in the gen_statem source code, so they are correct. + However, the generated descriptions also reflect the type hiearchy, + which makes them kind of hard to read. +

+

+ To get an overview of the concepts and operation of gen_statem, + do read the + User's Guide. + It frequently links back to this reference manual to avoid containing + detailed facts that may rot by age.

- - -

One for finite-state machines - (gen_fsm like), - which requires the state to be an atom and uses that state as - the name of the current callback function -

-
- -

One without restriction on the state data type - that uses one callback function for all states -

-
-

- This is a new behavior in Erlang/OTP 19.0. - It has been thoroughly reviewed, is stable enough - to be used by at least two heavy OTP applications, - and is here to stay. - Depending on user feedback, we do not expect - but can find it necessary to make minor - not backward compatible changes into Erlang/OTP 20.0. + This behavior appeared in Erlang/OTP 19.0. + In OTP 19.1 a backwards incompatible change of + the return tuple from + Module:init/1 + was made and the mandatory callback function + + Module:callback_mode/0 + + was introduced. In OTP 20.0 the + generic timeouts + were added.

- The gen_statem behavior replaces - gen_fsm in Erlang/OTP 20.0. - It has the same features and adds some really useful: + gen_statem has got the same features that + gen_fsm + had and adds some really useful:

Gathered state code. @@ -78,6 +82,27 @@ Reply from other state than the request. Multiple sys traceable replies. + + +

+ Two + callback modes + are supported: +

+ + +

One for finite-state machines + (gen_fsm like), + which requires the state to be an atom and uses that state as + the name of the current callback function +

+
+ +

One without restriction on the state data type + that uses one callback function for all states +

+
+

The callback model(s) for gen_statem differs from the one for gen_fsm, @@ -252,6 +277,16 @@ erlang:'!' -----> Module:StateName/3 to use after every event; see erlang:hibernate/3.

+

+ There is also a server start option + + {hibernate_after, Timeout} + + for + start/3,4 or + start_link/3,4 + that may be used to automatically hibernate the server. +

-- cgit v1.2.3