EQC.Pulse.Task.Supervisor
A tasks supervisor.
This module defines a supervisor which can be used to dynamically supervise tasks. Behind the scenes, this module is implemented as a :simple_one_for_one supervisor where the workers are temporary (i.e. they are not restarted after they die).
The functions in this module allow tasks to be spawned and awaited from a supervisor, similar to the functions defined in the Task module.
Name Registration
A Task.Supervisor is bound to the same name registration rules as a GenServer. Read more about it in the GenServer docs.
Summary
| async(supervisor, fun) | Starts a task that can be awaited on |
| async(supervisor, module, fun, args) | Starts a task that can be awaited on |
| children(supervisor) | Returns all children pids |
| start_child(supervisor, fun) | Starts a task as child of the given |
| start_child(supervisor, module, fun, args) | Starts a task as child of the given |
| start_link(opts \\ []) | Starts a new supervisor |
| terminate_child(supervisor, pid) | Terminates the child with the given |
Functions
Specs:
- async(EQC.Pulse.Supervisor.supervisor, (... -> any)) :: Task.t
Starts a task that can be awaited on.
The supervisor must be a reference as defined in Task.Supervisor. For more information on tasks, check the Task module.
Specs:
- async(EQC.Pulse.Supervisor.supervisor, module, atom, [term]) :: Task.t
Starts a task that can be awaited on.
The supervisor must be a reference as defined in Task.Supervisor. For more information on tasks, check the Task module.
Specs:
- start_child(EQC.Pulse.Supervisor.supervisor, (... -> any)) :: {:ok, pid}
Starts a task as child of the given supervisor.
Note that the spawned process is not linked to the caller, but only to the supervisor. This command is useful in case the task needs to perform side-effects (like I/O) and does not need to report back to the caller.
Specs:
- start_child(EQC.Pulse.Supervisor.supervisor, module, atom, [term]) :: {:ok, pid}
Starts a task as child of the given supervisor.
Similar to start_child/2 except the task is specified by the given module, fun and args.
Specs:
- start_link(EQC.Pulse.Supervisor.options) :: EQC.Pulse.Supervisor.on_start
Starts a new supervisor.
The supported options are:
:name- used to register a supervisor name, the supported values are described under theName Registrationsection in theGenServermodule docs;:restart- the restart strategy, may be:temporary(the default),:transientor:permanent. CheckSupervisor.Specfor more info. Defaults to temporary as most tasks can't be effectively restarted after a crash;:shutdown-:brutal_killif the tasks must be killed directly on shutdown or an integer indicating the timeout value, defaults to 5000 milliseconds;:max_restartsand:max_seconds- as specified inSupervisor.Spec.supervise/2;
Specs:
- terminate_child(EQC.Pulse.Supervisor.supervisor, pid) :: :ok
Terminates the child with the given pid.