gen_fsm v0.1.0 GenFSM behaviour

Summary

Types

Debug options supported by the start* functions

The fsm reference

The GenFSM name

Return values of start* functions

Option values used by the start* functions

Options used by the start* functions

Functions

Cancels an internal timer referred by reference in the GenFSM that calls this function

This function can be used by a GenFSM to explicitly send a reply to a client process

Sends an event asynchronously to the GenFSM and returns :ok immediately

Sends a delayed event internally in the GenFSM that calls this function after time in ms. Returns immediately a reference that can be used to cancel the delayed send using cancel_timer/1

Sends a timeout event internally in the GenFSM that calls this function after time set in ms. Returns immediately a reference that can be used to cancel the timer using cancel_timer/1

Sends an event to the GenFSM and waits until a reply arrives or a timeout occurs

Sends an event to the GenFSM and waits until a reply arrives or a timeout occurs

Types

debug :: [:trace | :log | :statistics | {:log_to_file, Path.t} | {:install, {(... -> any), any}}]

Debug options supported by the start* functions

event :: term
from :: {pid, tag :: term}
fsm_ref :: name | {name, node} | pid

The fsm reference

name ::
  atom |
  {:global, term} |
  {:via, module, term}

The GenFSM name

new_state_data :: term
next_state_name :: atom
on_start ::
  {:ok, pid} |
  :ignore |
  {:error, {:already_started, pid} | term}

Return values of start* functions

option ::
  {:debug, debug} |
  {:name, name} |
  {:timeout, timeout} |
  {:spawn_opt, Process.spawn_opt}

Option values used by the start* functions

options :: [option]

Options used by the start* functions

reason :: term
remaining_time :: integer
reply :: term
state_data :: term
state_name :: atom

Functions

cancel_timer(timer_ref)

Specs

cancel_timer(reference) :: remaining_time | false

Cancels an internal timer referred by reference in the GenFSM that calls this function.

reply(caller, reply)

Specs

reply(from, reply) :: :ok

This function can be used by a GenFSM to explicitly send a reply to a client process.

send_event(fsm_ref, event)

Specs

send_event(fsm_ref, event) :: :ok

Sends an event asynchronously to the GenFSM and returns :ok immediately.

send_event_after(time, event)

Specs

send_event_after(integer, event) :: reference

Sends a delayed event internally in the GenFSM that calls this function after time in ms. Returns immediately a reference that can be used to cancel the delayed send using cancel_timer/1.

start(module, args, options \\ [])

Specs

start(module, any, options) :: on_start
start_link(module, args, options \\ [])

Specs

start_link(module, any, options) :: on_start
start_timer(time, message)

Specs

start_timer(integer, term) :: reference

Sends a timeout event internally in the GenFSM that calls this function after time set in ms. Returns immediately a reference that can be used to cancel the timer using cancel_timer/1.

stop(fsm, reason \\ :normal, timeout \\ :infinity)

Specs

stop(fsm_ref, reason :: term, timeout) :: :ok
sync_send_all_state_event(fsm_ref, event, timeout)

Specs

sync_send_all_state_event(fsm_ref, event, timeout | :infinity) :: :ok

Sends an event to the GenFSM and waits until a reply arrives or a timeout occurs.

sync_send_event(fsm_ref, event)

Specs

sync_send_event(fsm_ref, event) :: :ok

Sends an event to the GenFSM and waits until a reply arrives or a timeout occurs.

Callbacks

code_change(old_vsn, state_name, state_data, extra)

Specs

code_change(old_vsn, state_name, state_data, extra :: term) ::
  {:ok, next_state_name, new_state_data} |
  {:error, reason} when old_vsn: term | {:down, term}
handle_event(event, state_name, state_data)

Specs

handle_event(event :: term, state_name, state_data) ::
  {:next_state, next_state_name, new_state_data} |
  {:next_state, next_state_name, new_state_data, timeout} |
  {:next_state, next_state_name, new_state_data, :hibernate} |
  {:stop, reason, new_state_data} when new_state_data: term
handle_info(info, state_name, state_data)

Specs

handle_info(info :: term, state_name, state_data) ::
  {:next_state, next_state_name, new_state_data} |
  {:next_state, next_state_name, new_state_data, timeout} |
  {:next_state, next_state_name, new_state_data, :hibernate} |
  {:stop, reason, new_state_data} when new_state_data: term
handle_sync_event(event, from, state_name, state_data)

Specs

handle_sync_event(event :: term, from :: {pid, tag :: term}, state_name, state_data) ::
  {:reply, reply, next_state_name, new_state_data} |
  {:reply, reply, next_state_name, new_state_data, timeout} |
  {:reply, reply, next_state_name, new_state_data, :hibernate} |
  {:next_state, next_state_name, new_state_data} |
  {:next_state, next_state_name, new_state_data, timeout} |
  {:next_state, next_state_name, new_state_data, :hibernate} |
  {:stop, reason, reply, new_state_data} |
  {:stop, reason, new_state_data} when new_state_data: term
init(args)

Specs

init(args :: term) ::
  {:ok, state_name, state_data} |
  {:ok, state_name, state_data, timeout | :hibernate} |
  :ignore |
  {:stop, reason}
terminate(reason, state_name, state_data)

Specs

terminate(reason, state_name, state_data) :: term when reason: :normal | :shutdown | {:shutdown, term} | term