View Source ebus_proc (ebus v0.3.0)

Process utilities.

Link to this section Summary

Functions

Equivalent to messages(self()).

Returns all queued messages for the process Pid.
Returns all queued messages for the process Pid, regardless if process is local or remote.

Spawns a process that stays receiving messages, and when a message is received, it applies the given callback {Mod, Fun, Args}.

Spawns a linked process that sleeps for the given Timeout, once timeout expires then process dies.
Waits the given Timeout for a message.

Link to this section Functions

Equivalent to messages(self()).

-spec messages(pid()) -> [term()].
Returns all queued messages for the process Pid.
-spec r_messages(pid()) -> [term()].
Returns all queued messages for the process Pid, regardless if process is local or remote.
Link to this function

spawn_callback_handler(Module, Fun, Args)

View Source

Equivalent to spawn_callback_handler(Module, Fun, Args, []).

Link to this function

spawn_callback_handler(Module, Fun, Args, Opts)

View Source
-spec spawn_callback_handler(module(), atom(), [term()], [term()]) -> pid() | {pid(), reference()}.

Spawns a process that stays receiving messages, and when a message is received, it applies the given callback {Mod, Fun, Args}.

Options:
  • Opts: Spawn process options. See erlang:spawn_opt/2.

See also: erlang:spawn_opt/2.

Equivalent to spawn_handler(Fun, []).

Link to this function

spawn_handler(Fun, Args)

View Source

Equivalent to spawn_handler(Fun, Args, []).

Link to this function

spawn_handler(Fun, Args, Opts)

View Source

Equivalent to spawn_callback_handler(erlang, apply, [Fun, Args], Opts).

Same as spawn_callback_handler/4, but receives a fun as callback. This fun is invoked as:

  apply(erlang, apply, [Fun, [Message | Args]])
Where Message is inserted as 1st argument in the fun args.
Link to this function

spawn_timer_fun(Timeout)

View Source
-spec spawn_timer_fun(timeout()) -> pid().
Spawns a linked process that sleeps for the given Timeout, once timeout expires then process dies.

Equivalent to wait_for_msg(infinity).

-spec wait_for_msg(timeout()) -> term() | {error, timeout}.
Waits the given Timeout for a message.