Skip to content

Commit 27f0b18

Browse files
authored
Add more docs about :already_started for DynamicSupervisor (#14298)
1 parent 491e4df commit 27f0b18

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

lib/elixir/lib/dynamic_supervisor.ex

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,14 @@ defmodule DynamicSupervisor do
230230
@typedoc "Supported strategies"
231231
@type strategy :: :one_for_one
232232

233-
@typedoc "Return values of `start_child` functions"
233+
@typedoc """
234+
Return values of `start_child` functions.
235+
236+
Unlike `Supervisor`, this module ignores the child spec ids, so
237+
`{:error, {:already_started, pid}}` is not returned for child specs given with the same id.
238+
`{:error, {:already_started, pid}}` is returned however if a duplicate name is used when using
239+
[name registration](`m:GenServer#module-name-registration`).
240+
"""
234241
@type on_start_child ::
235242
{:ok, pid}
236243
| {:ok, pid, info :: term}
@@ -400,11 +407,13 @@ defmodule DynamicSupervisor do
400407
@doc """
401408
Dynamically adds a child specification to `supervisor` and starts that child.
402409
403-
`child_spec` should be a valid child specification as detailed in the
404-
"Child specification" section of the documentation for `Supervisor`. The child
405-
process will be started as defined in the child specification. Note that while
410+
`child_spec` should be a valid [child specification](`m:Supervisor#module-child-specification`).
411+
The child process will be started as defined in the child specification. Note that while
406412
the `:id` field is still required in the spec, the value is ignored and
407-
therefore does not need to be unique.
413+
therefore does not need to be unique. Unlike `Supervisor`, this module does not
414+
return `{:error, {:already_started, pid}}` for child specs given with the same id.
415+
`{:error, {:already_started, pid}}` is returned however if a duplicate name is
416+
used when using [name registration](`m:GenServer#module-name-registration`).
408417
409418
If the child process start function returns `{:ok, child}` or `{:ok, child,
410419
info}`, then child specification and PID are added to the supervisor and

0 commit comments

Comments
 (0)