Skip to content

Commit 0f4a060

Browse files
committed
Merge pull request #1962 from UncleGrumpy/gen_server-exports
Define and export gen_server start types These changes are made under both the "Apache 2.0" and the "GNU Lesser General Public License 2.1 or later" license terms (dual license). SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
2 parents 51bb128 + 7c01dcb commit 0f4a060

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

libs/estdlib/src/gen_server.erl

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@
5454

5555
-export_type([
5656
server_ref/0,
57-
from/0
57+
from/0,
58+
start_ret/0,
59+
start_mon_ret/0
5860
]).
5961

6062
-record(state, {
@@ -64,6 +66,8 @@
6466
}).
6567

6668
-type options() :: list({atom(), term()}).
69+
-type start_ret() :: {ok, pid()} | {error, Reason :: term()}.
70+
-type start_mon_ret() :: {ok, {Pid :: pid(), MonRef :: reference()}} | {error, Reason :: term()}.
6771
-type server_ref() :: atom() | pid().
6872
-type from() :: any().
6973

@@ -258,7 +262,7 @@ crash_report(ErrStr, Parent, E, S) ->
258262
Module :: module(),
259263
Args :: term(),
260264
Options :: options()
261-
) -> {ok, pid()} | {error, Reason :: term()}.
265+
) -> start_ret().
262266
start({local, Name}, Module, Args, Options) when is_atom(Name) ->
263267
spawn_if_not_registered(Name, Module, Args, Options, []).
264268

@@ -275,7 +279,7 @@ start({local, Name}, Module, Args, Options) when is_atom(Name) ->
275279
%% @end
276280
%%-----------------------------------------------------------------------------
277281
-spec start(Module :: module(), Args :: term(), Options :: options()) ->
278-
{ok, pid()} | {error, Reason :: term()}.
282+
start_ret().
279283
start(Module, Args, Options) ->
280284
do_spawn(Module, Args, Options, []).
281285

@@ -299,7 +303,7 @@ start(Module, Args, Options) ->
299303
Module :: module(),
300304
Args :: term(),
301305
Options :: options()
302-
) -> {ok, pid()} | {error, Reason :: term()}.
306+
) -> start_ret().
303307
start_link({local, Name}, Module, Args, Options) when is_atom(Name) ->
304308
spawn_if_not_registered(Name, Module, Args, Options, [link]).
305309

@@ -316,7 +320,7 @@ start_link({local, Name}, Module, Args, Options) when is_atom(Name) ->
316320
%% @end
317321
%%-----------------------------------------------------------------------------
318322
-spec start_link(Module :: module(), Args :: term(), Options :: options()) ->
319-
{ok, pid()} | {error, Reason :: term()}.
323+
start_ret().
320324
start_link(Module, Args, Options) ->
321325
do_spawn(Module, Args, Options, [link]).
322326

@@ -334,7 +338,7 @@ start_link(Module, Args, Options) ->
334338
%% @end
335339
%%-----------------------------------------------------------------------------
336340
-spec start_monitor(Module :: module(), Args :: term(), Options :: options()) ->
337-
{ok, {Pid :: pid(), MonRef :: reference()}} | {error, Reason :: term()}.
341+
start_mon_ret().
338342
start_monitor(Module, Args, Options) ->
339343
do_spawn(Module, Args, Options, [monitor]).
340344

@@ -359,7 +363,7 @@ start_monitor(Module, Args, Options) ->
359363
Module :: module(),
360364
Args :: term(),
361365
Options :: options()
362-
) -> {ok, {Pid :: pid(), MonRef :: reference()}} | {error, Reason :: term()}.
366+
) -> start_mon_ret().
363367
start_monitor({local, Name}, Module, Args, Options) when is_atom(Name) ->
364368
spawn_if_not_registered(Name, Module, Args, Options, [monitor]).
365369

0 commit comments

Comments
 (0)