Skip to content

Commit

Permalink
Add more docs about :already_started for DynamicSupervisor (#14298)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamu authored Feb 25, 2025
1 parent 491e4df commit 27f0b18
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions lib/elixir/lib/dynamic_supervisor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,14 @@ defmodule DynamicSupervisor do
@typedoc "Supported strategies"
@type strategy :: :one_for_one

@typedoc "Return values of `start_child` functions"
@typedoc """
Return values of `start_child` functions.
Unlike `Supervisor`, this module ignores the child spec ids, so
`{:error, {:already_started, pid}}` is not returned for child specs given with the same id.
`{:error, {:already_started, pid}}` is returned however if a duplicate name is used when using
[name registration](`m:GenServer#module-name-registration`).
"""
@type on_start_child ::
{:ok, pid}
| {:ok, pid, info :: term}
Expand Down Expand Up @@ -400,11 +407,13 @@ defmodule DynamicSupervisor do
@doc """
Dynamically adds a child specification to `supervisor` and starts that child.
`child_spec` should be a valid child specification as detailed in the
"Child specification" section of the documentation for `Supervisor`. The child
process will be started as defined in the child specification. Note that while
`child_spec` should be a valid [child specification](`m:Supervisor#module-child-specification`).
The child process will be started as defined in the child specification. Note that while
the `:id` field is still required in the spec, the value is ignored and
therefore does not need to be unique.
therefore does not need to be unique. Unlike `Supervisor`, this module does not
return `{:error, {:already_started, pid}}` for child specs given with the same id.
`{:error, {:already_started, pid}}` is returned however if a duplicate name is
used when using [name registration](`m:GenServer#module-name-registration`).
If the child process start function returns `{:ok, child}` or `{:ok, child,
info}`, then child specification and PID are added to the supervisor and
Expand Down

0 comments on commit 27f0b18

Please sign in to comment.