ex_timer v0.1.2 ExTimer View Source

ExTimer module.

Link to this section Summary

Functions

add new timer

delete all the registerd timers

delete the previous registerd timer

Link to this section Types

Link to this section Functions

Link to this function add(state, msg, time) View Source
add(state(), tuple() | atom(), integer()) :: state()

add new timer.

Examples

iex> state = %{ __timers__: [] }
iex> state = ExTimer.add(state, {:handler, :name, "uhaha"}, 2000)
iex> [node] = state[:__timers__]
iex> node.msg == {:handler, :name, "uhaha"}
true
iex> node.time == 2000
true

delete all the registerd timers.

Examples

iex> state = %{__timers__: [%ExTimer.Node{msg: {:handler, :name, "uhaha"}, time: 2000}]}
iex> ExTimer.clear(state)
%{__timers__: []}
Link to this function remove(state, msg) View Source
remove(state(), tuple() | atom()) :: state()

delete the previous registerd timer.

Examples

iex> state = %{__timers__: [%ExTimer.Node{msg: {:handler, :name, "uhaha"}, time: 2000}]}
iex> ExTimer.remove(state, {:handler, :name, "uhaha"})
%{__timers__: []}