From f195d88713035ec23e4d1c2c2e09f73bb2178481 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Catalinas=20Jim=C3=A9nez?= Date: Fri, 24 Feb 2012 14:35:34 +0100 Subject: Remove trailing spaces --- lib/stdlib/src/supervisor.erl | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'lib/stdlib') diff --git a/lib/stdlib/src/supervisor.erl b/lib/stdlib/src/supervisor.erl index ac5b078c29..17e37e154e 100644 --- a/lib/stdlib/src/supervisor.erl +++ b/lib/stdlib/src/supervisor.erl @@ -566,13 +566,12 @@ check_flags(What) -> {bad_flags, What}. update_childspec(State, StartSpec) when ?is_simple(State) -> - case check_startspec(StartSpec) of - {ok, [Child]} -> - {ok, State#state{children = [Child]}}; - Error -> - {error, Error} - end; - + case check_startspec(StartSpec) of + {ok, [Child]} -> + {ok, State#state{children = [Child]}}; + Error -> + {error, Error} + end; update_childspec(State, StartSpec) -> case check_startspec(StartSpec) of {ok, Children} -> @@ -592,7 +591,7 @@ update_childspec1([Child|OldC], Children, KeepOld) -> end; update_childspec1([], Children, KeepOld) -> %% Return them in (kept) reverse start order. - lists:reverse(Children ++ KeepOld). + lists:reverse(Children ++ KeepOld). update_chsp(OldCh, Children) -> case lists:map(fun(Ch) when OldCh#child.name =:= Ch#child.name -> -- cgit v1.2.3 From c165d6c76fd99a0b3d91677b4531d9ee00c97dae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Catalinas=20Jim=C3=A9nez?= Date: Fri, 24 Feb 2012 14:36:05 +0100 Subject: Add the type restrictions in the code comments --- lib/stdlib/src/supervisor.erl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/stdlib') diff --git a/lib/stdlib/src/supervisor.erl b/lib/stdlib/src/supervisor.erl index 17e37e154e..b49550ff6d 100644 --- a/lib/stdlib/src/supervisor.erl +++ b/lib/stdlib/src/supervisor.erl @@ -1055,9 +1055,9 @@ remove_child(Child, State) -> %% Args: SupName = {local, atom()} | {global, atom()} | self %% Type = {Strategy, MaxIntensity, Period} %% Strategy = one_for_one | one_for_all | simple_one_for_one | -%% rest_for_one -%% MaxIntensity = integer() -%% Period = integer() +%% rest_for_one +%% MaxIntensity = integer() >= 0 +%% Period = integer() > 0 %% Mod :== atom() %% Args :== term() %% Purpose: Check that Type is of correct type (!) @@ -1108,7 +1108,7 @@ supname(N, _) -> N. %%% where Name is an atom %%% Func is {Mod, Fun, Args} == {atom(), atom(), list()} %%% RestartType is permanent | temporary | transient -%%% Shutdown = integer() | infinity | brutal_kill +%%% Shutdown = integer() > 0 | infinity | brutal_kill %%% ChildType = supervisor | worker %%% Modules = [atom()] | dynamic %%% Returns: {ok, [child_rec()]} | Error -- cgit v1.2.3 From 005fd391b1a212b09f45ee9900441014ec19c1a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Catalinas=20Jim=C3=A9nez?= Date: Fri, 24 Feb 2012 14:47:41 +0100 Subject: Fix supervisor doc: Shutdown, MaxR and MaxT type specs The next code snippets from supervisor.erl show that Shutdown from a child specification must be greater than zero and the same applies to MaxT. --- supervisor.erl ---------------------------------------------------------- validShutdown(Shutdown, _) when is_integer(Shutdown), Shutdown > 0 -> true; validShutdown(infinity, _) -> true; validShutdown(brutal_kill, _) -> true; validShutdown(Shutdown, _) -> throw({invalid_shutdown, Shutdown}). validIntensity(Max) when is_integer(Max), Max >= 0 -> true; validIntensity(What) -> throw({invalid_intensity, What}). validPeriod(Period) when is_integer(Period), Period > 0 -> true; validPeriod(What) -> throw({invalid_period, What}). ----------------------------------------------------------------------------- --- lib/stdlib/doc/src/supervisor.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/stdlib') diff --git a/lib/stdlib/doc/src/supervisor.xml b/lib/stdlib/doc/src/supervisor.xml index 33a7f5bb6a..ab360fbb6f 100644 --- a/lib/stdlib/doc/src/supervisor.xml +++ b/lib/stdlib/doc/src/supervisor.xml @@ -114,7 +114,7 @@ child_spec() = {Id,StartFunc,Restart,Shutdown,Type,Modules} M = F = atom() A = [term()] Restart = permanent | transient | temporary - Shutdown = brutal_kill | int()>=0 | infinity + Shutdown = brutal_kill | int()>0 | infinity Type = worker | supervisor Modules = [Module] | dynamic Module = atom() @@ -517,7 +517,8 @@ child_spec() = {Id,StartFunc,Restart,Shutdown,Type,Modules} Args = term() Result = {ok,{{RestartStrategy,MaxR,MaxT},[ChildSpec]}} | ignore  RestartStrategy = strategy() -  MaxR = MaxT = integer()>=0 +  MaxR = integer()>=0 +  MaxT = integer()>0  ChildSpec = child_spec() -- cgit v1.2.3 From b5b00bef5d654006b15c44abbfe5aae3de9d3572 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Catalinas=20Jim=C3=A9nez?= Date: Fri, 24 Feb 2012 15:03:21 +0100 Subject: Cosmetic: split very long lines from supervisor doc --- lib/stdlib/doc/src/supervisor.xml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'lib/stdlib') diff --git a/lib/stdlib/doc/src/supervisor.xml b/lib/stdlib/doc/src/supervisor.xml index ab360fbb6f..ff06b04d07 100644 --- a/lib/stdlib/doc/src/supervisor.xml +++ b/lib/stdlib/doc/src/supervisor.xml @@ -55,7 +55,8 @@ monitoring its child processes. The basic idea of a supervisor is that it should keep its child processes alive by restarting them when necessary.

-

The children of a supervisor is defined as a list of child specifications. When the supervisor is started, the child +

The children of a supervisor is defined as a list of + child specifications. When the supervisor is started, the child processes are started in order from left to right according to this list. When the supervisor terminates, it first terminates its child processes in reversed start order, from right to left.

@@ -100,7 +101,8 @@

To prevent a supervisor from getting into an infinite loop of - child process terminations and restarts, a maximum restart frequency is defined using two integer values MaxR + child process terminations and restarts, a maximum restart frequency + is defined using two integer values MaxR and MaxT. If more than MaxR restarts occur within MaxT seconds, the supervisor terminates all child processes and then itself. @@ -197,7 +199,8 @@ child_spec() = {Id,StartFunc,Restart,Shutdown,Type,Modules} the callback module, if the child process is a supervisor, gen_server or gen_fsm. If the child process is an event manager (gen_event) with a dynamic set of callback modules, - Modules should be dynamic. See OTP Design Principles for more information about release handling.

+ Modules should be dynamic. See OTP Design Principles + for more information about release handling.

Internally, the supervisor also keeps track of the pid @@ -434,7 +437,8 @@ child_spec() = {Id,StartFunc,Restart,Shutdown,Type,Modules} - Return information about all children specifications and child processes belonging to a supervisor. + Return information about all children specifications and + child processes belonging to a supervisor.

Returns a newly created list with information about all child specifications and child processes belonging to @@ -467,7 +471,8 @@ child_spec() = {Id,StartFunc,Restart,Shutdown,Type,Modules} - Return counts for the number of childspecs, active children, supervisors and workers. + Return counts for the number of childspecs, active children, + supervisors and workers.

Returns a property list (see proplists) containing the counts for each of the following elements of the supervisor's -- cgit v1.2.3