View Source Protean.Interpreter.Hooks (Protean v0.1.0)
Interpreter execution hooks.
The purpose of this module is to define extensions at various points of machine interpretation.
See the description of the interpretation loop in Protean.Interpreter
before reading on.
While hooks can implement "standalone" behaviors, such as ignoring a certain type of event,
they are used by Protean to implement higher-level features such as :spawn
.
See Protean.Interpreter.Features
for more.
hooks
Hooks
event_filter
is used to filter out or modify events.after_event_filter
is used to perform setup that you'd only want to occur if the event was not filtered out.after_microstep
runs after a microstep has occurred.after_macrostep
runs after a macrostep has occurred.on_stop
runs when interpretation stops.
See function documentation for the individual hooks below.
Link to this section Summary
Functions
Register an after_event_fitler
hook.
Register an after_macrostep
hook.
Register an after_microstep
hook.
Register an event_filter
hook.
Register an on_stop
hook.
Link to this section Functions
Register an after_event_fitler
hook.
Function must accept two arguments, interpreter
and event
, and must return
{:cont, interpreter
}.
Register an after_macrostep
hook.
Function must accept an interpreter
and return {:cont, interpreter
}.
Register an after_microstep
hook.
Function must accept interpreter
and return {:cont, interpreter
}.
Register an event_filter
hook.
Function must accept one argument, {interpreter, event}
and return one of:
{:cont, {interpreter, event}}
- continue with interpreter and event{:halt, interpreter}
- halt with interpreter and ignore event
Register an on_stop
hook.
Function must accept an interpreter
and return {:cont, interpreter
}.