gen_timer v1.0.0 GenTimer behaviour View Source
Extends GenServer to give a timer functionality.
There is a small folder of examples in this repo to guide you.
Callbacks
Supports the same callbacks as GenServer. The only considerations are:
There Is Required State For init/1
The state returned by GenServer.init/1 must include the required keys shown
in valid_state/0, but then you can add any other state you please.
Repeated Funtion Callback
The callback repeated_function/1 is where you choose what is done each
iteration. It will use the current state as the argument and will use the
returned state as the state of the GenServer going forward.
Link to this section Summary
Functions
Use exactly the same as GenServer.start/3.
Use exactly the same as GenServer.start_link/3.
Callbacks
This is where you choose what is done each iteration.
Link to this section Types
valid_state()
View Sourcevalid_state() :: %{
milli: pos_integer(),
times: pos_integer() | :infinite,
last_return: any()
}
Link to this section Functions
See GenServer.abcast/3.
See GenServer.call/3.
See GenServer.cast/2.
See GenServer.reply/2.
start(module, args, options)
View Sourcestart(atom(), any(), GenServer.options()) :: GenServer.on_start()
Use exactly the same as GenServer.start/3.
Only difference is that it will send a message to the process to start the timer.
start_link(module, args, options)
View Sourcestart_link(atom(), any(), GenServer.options()) :: GenServer.on_start()
Use exactly the same as GenServer.start_link/3.
Only difference is that it will send a message to the process to start the timer.
See GenServer.stop/3.
Link to this section Callbacks
repeated_function(state)
View Sourcerepeated_function(state :: valid_state()) :: valid_state()
This is where you choose what is done each iteration.
It will use the current state as the argument and will use the returned state as the state of the GenServer going forward.