View Source Protean.Interpreter (Protean v0.1.0-alpha.3)

Execution logic for a Protean machine.

Link to this section Summary

Functions

Return the current machine context.

Handle an event, executing any transitions, actions, and side-effects associated with the current machine context.

Create a new Interpreter. The returned interpreter will still need to be started, which could result in additional side-effects. See start/1.

Whether the interpreter has been started and can accept events.

Entrypoint for the interpreter that must be called before the interpreter will be in a state where it can handle external events. This is necessary in order to handle any initializing actions, invokes, or automatic transitions.

Stop an interpreter, preventing further event processing and terminating any invoked processes.

Link to this section Types

@type t() :: %Protean.Interpreter{
  config: Protean.MachineConfig.t(),
  context: Protean.Context.t(),
  id: Protean.id() | nil,
  internal_queue: :queue.queue(),
  parent: pid(),
  running: boolean()
}

Link to this section Functions

@spec context(t()) :: Protean.Context.t()

Return the current machine context.

Link to this function

handle_event(interpreter, event)

View Source
@spec handle_event(t(), Protean.event()) :: {t(), [term()]}

Handle an event, executing any transitions, actions, and side-effects associated with the current machine context.

Returns a tuple of the interpreter and any replies resulting from actions that were run.

@spec new(keyword()) :: t()

Create a new Interpreter. The returned interpreter will still need to be started, which could result in additional side-effects. See start/1.

@spec running?(t()) :: boolean()

Whether the interpreter has been started and can accept events.

@spec start(t()) :: t()

Entrypoint for the interpreter that must be called before the interpreter will be in a state where it can handle external events. This is necessary in order to handle any initializing actions, invokes, or automatic transitions.

Calling start/1 on an already-running interpreter is a no-op.

@spec stop(t()) :: t()

Stop an interpreter, preventing further event processing and terminating any invoked processes.