Task utility.
Conveniences for spawning and awaiting tasks.
This module is based on Elixir Taskcallback() = {module(), atom(), [term()]}
info() = {node(), pid() | atom()}
Process info.
link() = link | monitor | nolink
proc_info() = {node(), pid() | atom()}
task() = #{pid => pid() | nil, ref => reference() | nil, owner => pid() | nil}
task_fun() = fun(() -> term()) | fun((term()) -> term())
| async/1 | Equivalent to async(erlang, apply, [Fun, []]).
|
| async/2 | Equivalent to async(erlang, apply, [Fun, Args]).
|
| async/3 | Starts a task that must be awaited on. |
| await/1 | Equivalent to await(Task, 5000).
|
| await/2 | Awaits a task reply. |
| start/1 | Starts a task. |
| start/2 | Starts a task. |
| start/3 | Starts a task. |
| start_link/1 | Starts a task as part of a supervision tree. |
| start_link/2 | Starts a task as part of a supervision tree. |
| start_link/3 | Starts a task as part of a supervision tree. |
async(Fun) -> any()
Equivalent to async(erlang, apply, [Fun, []]).
async(Fun, Args) -> any()
Equivalent to async(erlang, apply, [Fun, Args]).
async(Mod::module(), Fun::atom(), Args::[term()]) -> task()
Starts a task that must be awaited on.
Atask() type is returned containing the relevant information.
Developers must eventually call await/2 on the returned task.
await(Task) -> any()
Equivalent to await(Task, 5000).
await(Task::task(), Timeout::timeout()) -> term() | no_return()
Awaits a task reply.
A timeout, in milliseconds, can be given with default value
of 5000. In case the task process dies, this function will
exit with the same reason as the task.
If the timeout is exceeded, await will exit, however,
the task will continue to run. When the calling process exits, its
exit signal will terminate the task if it is not trapping exits.
This function assumes the task's monitor is still active or the monitor's
DOWN message is in the message queue. If it has been demonitored, or the
message already received, this function may wait for the duration of the
timeout awaiting the message.
start(Fun::task_fun()) -> {ok, pid()}
Starts a task.
This is only used when the task is used for side-effects (i.e. no interest in the returned result) and it should not be linked to the current process.start(Fun::task_fun(), Args::[term()]) -> {ok, pid()}
Starts a task.
This is only used when the task is used for side-effects (i.e. no interest in the returned result) and it should not be linked to the current process.start(Mod::module(), Fun::atom(), Args::[term()]) -> {ok, pid()}
Starts a task.
This is only used when the task is used for side-effects (i.e. no interest in the returned result) and it should not be linked to the current process.start_link(Fun::task_fun()) -> {ok, pid()}
Starts a task as part of a supervision tree.
start_link(Fun::task_fun(), Args::[term()]) -> {ok, pid()}
Starts a task as part of a supervision tree.
start_link(Mod::module(), Fun::atom(), Args::[term()]) -> {ok, pid()}
Starts a task as part of a supervision tree.
Generated by EDoc