Types
Args = term()
Result = {ok,State} | {ok,State,Timeout} | {ok,State,hibernate}
| {ok,State,{continue,Continue}} | {stop,Reason} | ignore
State = term()
Timeout = int()>=0 | infinity
Reason = term()
Whenever a gen_server process is started using
start/3,4,
start_monitor/3,4,
or start_link/3,4,
this function is called by the new process to initialize.
Args is the Args argument provided to the start
function.
If the initialization is successful, the function is to
return {ok,State}, {ok,State,Timeout},
{ok,State,hibernate}, or {ok,State,{continue,Continue}}
where State is the internal state of the gen_server
process.
If an integer time-out value is provided, a time-out occurs
unless a request or a message is received within
Timeout milliseconds. A time-out is represented by
the atom timeout, which is to be handled by the
Module:handle_info/2 callback function. The atom
infinity can be used to wait indefinitely, this is
the default value.
If hibernate is specified instead of a time-out value,
the process goes into
hibernation when waiting for the next message to arrive (by calling
proc_lib:hibernate/3).
If {continue,Continue} is specified, the process will
execute the
Module:handle_continue/2 callback function, with
Continue as the first argument.
If the initialization fails, the function is to return
{stop,Reason}, where Reason is any term, or
ignore. An exit signal with this Reason (or with reason
normal if ignore is returned) is sent to linked
processes and ports, notably to the process starting the gen_server
when start_link/3,4
is used.