Skip to content

Commit

Permalink
supervisor: use proc_libs types
Browse files Browse the repository at this point in the history
  • Loading branch information
kikofernandez committed Jun 5, 2023
1 parent 8dc1a5a commit 78b2223
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
7 changes: 5 additions & 2 deletions lib/stdlib/doc/src/supervisor.xml
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,9 @@ child_spec() = #{id => child_id(), % mandatory
<datatype>
<name name="sup_ref"/>
</datatype>
<datatype>
<name name="sup_name"/>
</datatype>
<datatype>
<name name="worker"/>
</datatype>
Expand Down Expand Up @@ -631,14 +634,14 @@ child_spec() = #{id => child_id(), % mandatory
</item>
<item>
<p>If
<c><anno>SupName</anno>={via,<anno>Module</anno>,<anno>Name</anno>}</c>,
<c><anno>SupName</anno>={via,<anno>Module</anno>,Name}</c>,
the supervisor is registered as <c>Name</c> using the registry
represented by <c>Module</c>. The <c>Module</c> callback must
export the functions <c>register_name/2</c>,
<c>unregister_name/1</c>, and <c>send/2</c>, which must behave
like the corresponding functions in
<seeerl marker="kernel:global"><c>global</c></seeerl>. Thus,
<c>{via,global,<anno>Name</anno>}</c> is a valid reference.</p>
<c>{via,global,Name}</c> is a valid reference.</p>
</item>
</list>
<p>If no name is provided, the supervisor is not registered.</p>
Expand Down
12 changes: 3 additions & 9 deletions lib/stdlib/src/supervisor.erl
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

-export_type([sup_flags/0, child_spec/0, strategy/0,
startchild_ret/0, startchild_err/0,
startlink_ret/0, startlink_err/0]).
startlink_ret/0, startlink_err/0, sup_name/0, sup_ref/0]).

%%--------------------------------------------------------------------------

Expand All @@ -71,14 +71,8 @@
-type significant() :: boolean().
-type shutdown() :: 'brutal_kill' | timeout().
-type worker() :: 'worker' | 'supervisor'.
-type sup_name() :: {'local', Name :: atom()}
| {'global', Name :: term()}
| {'via', Module :: module(), Name :: any()}.
-type sup_ref() :: (Name :: atom())
| {Name :: atom(), Node :: node()}
| {'global', Name :: term()}
| {'via', Module :: module(), Name :: any()}
| pid().
-type sup_name() :: proc_lib:sup_name().
-type sup_ref() :: proc_lib:sup_ref().
-type child_spec() :: #{id := child_id(), % mandatory
start := mfargs(), % mandatory
restart => restart(), % optional
Expand Down

0 comments on commit 78b2223

Please sign in to comment.