GenLoop v0.1.0 GenLoop behaviour

Link to this section Summary

Types

Debug options supported by the start* functions

Tuple describing the client of a call request. pid is the PID of the caller and tag is a unique term used to identify the call

The GenLoop name

Return values of start* functions

Option values used by the start* functions

Options used by the start* functions

The server reference

Link to this section Types

Link to this type debug()
debug() :: [:trace | :log | :statistics | {:log_to_file, Path.t}]

Debug options supported by the start* functions

Link to this type from()
from() :: {pid, tag :: term}

Tuple describing the client of a call request. pid is the PID of the caller and tag is a unique term used to identify the call.

Link to this type name()
name() :: atom | {:global, term} | {:via, module, term}

The GenLoop name

Link to this type on_start()
on_start ::
  {:ok, pid} |
  :ignore |
  {:error, {:already_started, pid} | term}

Return values of start* functions

Link to this type option()
option ::
  {:debug, debug} |
  {:name, name} |
  {:timeout, timeout} |
  {:spawn_opt, Process.spawn_opt}

Option values used by the start* functions

Link to this type options()
options() :: [option]

Options used by the start* functions

Link to this type server()
server() :: pid | name | {atom, node}

The server reference

Link to this section Functions

Link to this function abcast(nodes, server, term)
abcast([node], name :: atom, term) :: :abcast

See GenServer.abcast/3.

Link to this function call(server, request, timeout \\ 5000)
call(server, term, timeout) :: term
Link to this function cast(server, term)
cast(server, term) :: term

See GenServer.cast/2.

Link to this macro from_pid(from) (macro)
Link to this macro hibernate(module, function, args) (macro)
Link to this function multi_call(nodes \\ [node() | Node.list()], name, request, timeout \\ :infinity)
multi_call([node], name :: atom, term, timeout) :: {replies :: [{node, term}], bad_nodes :: [node]}
Link to this macro rcall(from, msg) (macro)
Link to this macro rcast(msg) (macro)
Link to this macro receive(state_var, blocks) (macro)
Link to this function reply(from, term)
reply(from, term) :: :ok

See GenServer.reply/2.

Link to this function send(server, message)
send(server, term) :: term

Behaves just like Kernel.send but accepts atoms or registry tuples on top of pids to identify a process.

Link to this function start(module, args, options \\ [])
start(module, any, options) :: on_start
Link to this function start_link(module, args, options \\ [])
start_link(module, any, options) :: on_start
Link to this function stop(server, reason)

See GenServer.stop/2.

Link to this function stop(server, reason, timeout)
stop(server, reason :: term, timeout) :: :ok

See GenServer.stop/3.

Link to this function whereis(name)
whereis(server) :: pid | {atom, node} | nil

See GenServer.whereis/1.

Link to this section Callbacks

Link to this callback code_change(old_vsn, state, extra)
code_change(old_vsn, state :: term, extra :: term) ::
  {:ok, new_state :: term} |
  {:error, reason :: term} when old_vsn: term | {:down, term}
Link to this callback data_vsn()
data_vsn() :: term
Link to this callback format_status(reason, pdict_and_state) (optional)
format_status(reason, pdict_and_state :: list) :: term when reason: :normal | :terminate
Link to this callback init(args)
init(args :: term) ::
  {:ok, state} |
  {:ok, state, timeout | :hibernate} |
  :ignore |
  {:stop, reason :: any} when state: any
Link to this callback terminate(reason, state)
terminate(reason, state :: term) :: term when reason: :normal | :shutdown | {:shutdown, term} | term