Task.Supervisor.start_child
start_child, go back to Task.Supervisor module for more information.
Specs
start_child(Supervisor.supervisor(), (() -> any()), keyword()) :: DynamicSupervisor.on_start_child()
Starts a task as a child of the given supervisor.
Task.Supervisor.start_child(MyTaskSupervisor, fn ->
IO.puts "I am running in a task"
end)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 you have no interest on its results nor if it completes successfully.
Options
:restart- the restart strategy, may be:temporary(the default),:transientor:permanent.:temporarymeans the task is never restarted,:transientmeans it is restarted if the exit is not:normal,:shutdownor{:shutdown, reason}. A:permanentrestart strategy means it is always restarted. It defaults to:temporary.:shutdown-:brutal_killif the tasks must be killed directly on shutdown or an integer indicating the timeout value, defaults to 5000 milliseconds.
Specs
start_child(Supervisor.supervisor(), module(), atom(), [term()], keyword()) :: DynamicSupervisor.on_start_child()
Starts a task as a child of the given supervisor.
Similar to start_child/2 except the task is specified
by the given module, fun and args.