Process.send_after
send_after
, go back to Process module for more information.
Specs
send_after(pid() | atom(), term(), non_neg_integer(), [option]) :: reference() when option: {:abs, boolean()}
Sends msg
to dest
after time
milliseconds.
If dest
is a PID, it must be the PID of a local process, dead or alive.
If dest
is an atom, it must be the name of a registered process
which is looked up at the time of delivery. No error is produced if the name does
not refer to a process.
The message is not sent immediately. Therefore, dest
can receive other messages
in-between even when time
is 0
.
This function returns a timer reference, which can be read with read_timer/1
or canceled with cancel_timer/1
.
The timer will be automatically canceled if the given dest
is a PID
which is not alive or when the given PID exits. Note that timers will not be
automatically canceled when dest
is an atom (as the atom resolution is done
on delivery).
Inlined by the compiler.
Options
:abs
- (boolean) whenfalse
,time
is treated as relative to the current monotonic time. Whentrue
,time
is the absolute value of the Erlang monotonic time at whichmsg
should be delivered todest
. To read more about Erlang monotonic time and other time-related concepts, look at the documentation for theSystem
module. Defaults tofalse
.
Examples
timer_ref = Process.send_after(pid, :hi, 1000)