From 17da9d0d5e08ef313055cf799fec7ee856fde1d4 Mon Sep 17 00:00:00 2001
From: Raimo Niskanen
Date: Mon, 25 Feb 2019 12:10:40 +0100
Subject: Create a gen_statem type for enter_loop options
---
lib/stdlib/doc/src/gen_statem.xml | 63 ++++++++++++++++++++-------------------
lib/stdlib/doc/src/sys.xml | 5 +++-
lib/stdlib/src/gen_statem.erl | 38 +++++++++++------------
lib/stdlib/src/sys.erl | 28 ++++++++---------
4 files changed, 67 insertions(+), 67 deletions(-)
(limited to 'lib')
diff --git a/lib/stdlib/doc/src/gen_statem.xml b/lib/stdlib/doc/src/gen_statem.xml
index dfecd235c9..0a7619baf5 100644
--- a/lib/stdlib/doc/src/gen_statem.xml
+++ b/lib/stdlib/doc/src/gen_statem.xml
@@ -4,7 +4,7 @@
- 20162018
+ 20162019
Ericsson AB. All Rights Reserved.
@@ -513,36 +513,6 @@ handle_event(_, _, State, Data) ->
-
-
-
-
- Debug option that can be used when starting
- a gen_statem server through,
- enter_loop/4-6.
-
-
- For every entry in Dbgs,
- the corresponding function in
- sys is called.
-
-
-
-
-
-
-
- hibernate_after option that can be used when starting
- a gen_statem server through,
- enter_loop/4-6.
-
- If option{hibernate_after,HibernateAfterTimeout} is present, the gen_statem
- process awaits any message for HibernateAfterTimeout milliseconds and
- if no message is received, the process goes into hibernation automatically
- (by calling proc_lib:hibernate/3).
-
-
-
@@ -562,6 +532,37 @@ handle_event(_, _, State, Data) ->
+
+
+
+
+ Options that can be used when starting
+ a gen_statem server through,
+ enter_loop/4-6.
+
+
+ hibernate_after
+ -
+
+ HibernateAfterTimeout
+ specifies that the gen_statem process awaits
+ any message for HibernateAfterTimeout milliseconds and
+ if no message is received, the process goes into hibernation
+ automatically (by calling
+ proc_lib:hibernate/3).
+
+
+ debug
+ -
+
+ For every entry in Dbgs,
+ the corresponding function in
+ sys is called.
+
+
+
+
+
diff --git a/lib/stdlib/doc/src/sys.xml b/lib/stdlib/doc/src/sys.xml
index 9fe816e33a..bf48ae0723 100644
--- a/lib/stdlib/doc/src/sys.xml
+++ b/lib/stdlib/doc/src/sys.xml
@@ -4,7 +4,7 @@
- 19962018
+ 19962019
Ericsson AB. All Rights Reserved.
@@ -122,6 +122,9 @@
+
+
+
diff --git a/lib/stdlib/src/gen_statem.erl b/lib/stdlib/src/gen_statem.erl
index 5f5af7d38f..3a747b6104 100644
--- a/lib/stdlib/src/gen_statem.erl
+++ b/lib/stdlib/src/gen_statem.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2016-2018. All Rights Reserved.
+%% Copyright Ericsson AB 2016-2019. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
@@ -71,9 +71,9 @@
-export_type(
[server_name/0,
server_ref/0,
- hibernate_after_opt/0,
start_opt/0,
- start_ret/0]).
+ start_ret/0,
+ enter_loop_opt/0]).
%%%==========================================================================
%%% Interface functions.
@@ -431,28 +431,26 @@ timeout_event_type(Type) ->
%%% API
-type server_name() ::
- {'global', GlobalName :: term()}
+ {'global', GlobalName :: term()}
| {'via', RegMod :: module(), Name :: term()}
| {'local', atom()}.
-type server_ref() ::
- pid()
+ pid()
| (LocalName :: atom())
| {Name :: atom(), Node :: atom()}
| {'global', GlobalName :: term()}
| {'via', RegMod :: module(), ViaName :: term()}.
--type debug_opt() ::
- {'debug',
- Dbgs ::
- ['trace' | 'log' | 'statistics' | 'debug'
- | {'logfile', string()}]}.
--type hibernate_after_opt() ::
- {'hibernate_after', HibernateAfterTimeout :: timeout()}.
-type start_opt() ::
- debug_opt()
- | {'timeout', Time :: timeout()}
- | hibernate_after_opt()
- | {'spawn_opt', [proc_lib:spawn_option()]}.
--type start_ret() :: {'ok', pid()} | 'ignore' | {'error', term()}.
+ {'timeout', Time :: timeout()}
+ | {'spawn_opt', [proc_lib:spawn_option()]}
+ | enter_loop_opt().
+-type start_ret() ::
+ {'ok', pid()}
+ | 'ignore'
+ | {'error', term()}.
+-type enter_loop_opt() ::
+ {'hibernate_after', HibernateAfterTimeout :: timeout()}
+ | {'debug', Dbgs :: [sys:debug_option()]}.
@@ -565,14 +563,14 @@ reply({To,Tag}, Reply) when is_pid(To) ->
%% started by proc_lib into a state machine using
%% the same arguments as you would have returned from init/1
-spec enter_loop(
- Module :: module(), Opts :: [debug_opt() | hibernate_after_opt()],
+ Module :: module(), Opts :: [enter_loop_opt()],
State :: state(), Data :: data()) ->
no_return().
enter_loop(Module, Opts, State, Data) ->
enter_loop(Module, Opts, State, Data, self()).
%%
-spec enter_loop(
- Module :: module(), Opts :: [debug_opt() | hibernate_after_opt()],
+ Module :: module(), Opts :: [enter_loop_opt()],
State :: state(), Data :: data(),
Server_or_Actions ::
server_name() | pid() | [action()]) ->
@@ -586,7 +584,7 @@ enter_loop(Module, Opts, State, Data, Server_or_Actions) ->
end.
%%
-spec enter_loop(
- Module :: module(), Opts :: [debug_opt() | hibernate_after_opt()],
+ Module :: module(), Opts :: [enter_loop_opt()],
State :: state(), Data :: data(),
Server :: server_name() | pid(),
Actions :: [action()] | action()) ->
diff --git a/lib/stdlib/src/sys.erl b/lib/stdlib/src/sys.erl
index 0064414d6f..e97f9bb342 100644
--- a/lib/stdlib/src/sys.erl
+++ b/lib/stdlib/src/sys.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2018. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2019. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
@@ -36,7 +36,7 @@
%% Types
%%-----------------------------------------------------------------
--export_type([dbg_opt/0]).
+-export_type([dbg_opt/0, dbg_fun/0, debug_option/0]).
-type name() :: pid() | atom()
| {'global', term()}
@@ -67,6 +67,16 @@
Event :: system_event(),
Extra :: term()) -> any()).
+-type debug_option() ::
+ 'trace'
+ | 'log'
+ | {'log', N :: pos_integer()}
+ | 'statistics'
+ | {'log_to_file', FileName :: file:name()}
+ | {'install',
+ {Func :: dbg_fun(), FuncState :: term()}
+ | {FuncId :: term(), Func :: dbg_fun(), FuncState :: term()}}.
+
%%-----------------------------------------------------------------
%% System messages
%%-----------------------------------------------------------------
@@ -646,19 +656,7 @@ close_log_file(Debug) ->
%% Returns: [debug_opts()]
%%-----------------------------------------------------------------
--spec debug_options(Options) -> [dbg_opt()] when
- Options :: [Opt],
- Opt :: 'trace'
- | 'log'
- | {'log', pos_integer()}
- | 'statistics'
- | {'log_to_file', FileName}
- | {'install', FuncSpec},
- FileName :: file:name(),
- FuncSpec :: {Func, FuncState} | {FuncId, Func, FuncState},
- FuncId :: term(),
- Func :: dbg_fun(),
- FuncState :: term().
+-spec debug_options([Opt :: debug_option()]) -> [dbg_opt()].
debug_options(Options) ->
debug_options(Options, []).
--
cgit v1.2.3