This behavior module provides the server of a client-server
relation. A generic server process (
A
gen_server module Callback module ----------------- --------------- gen_server:start gen_server:start_link -----> Module:init/1 gen_server:stop -----> Module:terminate/2 gen_server:call gen_server:multi_call -----> Module:handle_call/3 gen_server:cast gen_server:abcast -----> Module:handle_cast/2 - -----> Module:handle_info/2 - -----> Module:terminate/2 - -----> Module:code_change/3
If a callback function fails or returns a bad value, the
A
Notice that a
Unless otherwise stated, all functions in this module fail if
the specified
The
Sends an asynchronous request to the
For a description of the arguments, see
Makes a synchronous call to the
The return value
The call can fail for many reasons, including time-out and the
called
Sends an asynchronous request to the
For a description of
Makes an existing process into a
This function is useful when a more complex initialization procedure
is needed than the
The function fails if the calling process was not started by a
Makes a synchronous call to all
The function returns a tuple
When a reply
If one of the nodes cannot process monitors, for example,
C or Java nodes, and the
This problem does not exist if all nodes are Erlang nodes.
To prevent late answers (after the time-out) from polluting the message queue of the caller, a middleman process is used to do the calls. Late answers are then discarded when they arrive to a terminated process.
This function can be used by a
The return value
Creates a standalone
For a description of arguments and return values, see
Creates a
The
If
If
If
If option
If option
If option
Using spawn option
If the
If
Orders a generic server to exit with the specified
The function returns
If the process does not exist, a
The following functions
are to be exported from a
This callback is optional, so callback modules need not export it.
If a release upgrade/downgrade with
This function is called by a
For an upgrade,
If successful, the function must return the updated internal state.
If the function returns
This callback is optional, so callback modules need not
export it. The
This function is called by a
One of
The
This function is useful for changing the form and
appearance of the
The function is to return
One use for this function is to return compact alternative state representations to avoid that large state terms are printed in log files.
Whenever a
If
For a description of
If
If
If
Whenever a
For a description of the arguments and possible return values, see
This callback is optional, so callback modules need not
export it. The
This function is called by a
For a description of the other arguments and possible return values,
see
Whenever a
If the initialization is successful, the function is to
return
If an integer time-out value is provided, a time-out occurs
unless a request or a message is received within
If
If the initialization fails, the function is to return
This callback is optional, so callback modules need not
export it. The
This function is called by a
If the
The
The shutdown strategy as defined in the child specification
of the supervisor is an integer time-out value, not
Even if the
Otherwise, the
Notice that for any other reason than