3. gen_fsm Behaviour

3 gen_fsm Behaviour

This section is to be read with the gen_fsm(3) manual page in STDLIB, where all interface functions and callback functions are described in detail.

3.1 Finite-State Machines

A Finite-State Machine (FSM) can be described as a set of relations of the form:

State(S) x Event(E) -> Actions(A), State(S')

These relations are interpreted as meaning:

If we are in state S and event E occurs, we are to perform actions A and make a transition to state S'.

For an FSM implemented using the gen_fsm behaviour, the state transition rules are written as a number of Erlang functions, which conform to the following convention:

StateName(Event, StateData) ->