aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src/supervisor.erl
diff options
context:
space:
mode:
authorRickard Green <[email protected]>2014-12-17 22:18:27 +0100
committerRickard Green <[email protected]>2015-03-20 15:28:53 +0100
commitfbaa0becc787e73fa539e0d497b0d74be27c9534 (patch)
treec89e004b5e33d51ca07635678415c8dc4e8f2f23 /lib/stdlib/src/supervisor.erl
parent1d9350693fe2c4d1d6b2baa504aacd070e023a1a (diff)
downloadotp-fbaa0becc787e73fa539e0d497b0d74be27c9534.tar.gz
otp-fbaa0becc787e73fa539e0d497b0d74be27c9534.tar.bz2
otp-fbaa0becc787e73fa539e0d497b0d74be27c9534.zip
Replace usage of erlang:now() with usage of new API
Diffstat (limited to 'lib/stdlib/src/supervisor.erl')
-rw-r--r--lib/stdlib/src/supervisor.erl17
1 files changed, 2 insertions, 15 deletions
diff --git a/lib/stdlib/src/supervisor.erl b/lib/stdlib/src/supervisor.erl
index ede2742875..4979179b5c 100644
--- a/lib/stdlib/src/supervisor.erl
+++ b/lib/stdlib/src/supervisor.erl
@@ -1312,7 +1312,7 @@ add_restart(State) ->
I = State#state.intensity,
P = State#state.period,
R = State#state.restarts,
- Now = erlang:now(),
+ Now = erlang:monotonic_time(1),
R1 = add_restart([Now|R], Now, P),
State1 = State#state{restarts = R1},
case length(R1) of
@@ -1333,26 +1333,13 @@ add_restart([], _, _) ->
[].
inPeriod(Time, Now, Period) ->
- case difference(Time, Now) of
+ case Time - Now of
T when T > Period ->
false;
_ ->
true
end.
-%%
-%% Time = {MegaSecs, Secs, MicroSecs} (NOTE: MicroSecs is ignored)
-%% Calculate the time elapsed in seconds between two timestamps.
-%% If MegaSecs is equal just subtract Secs.
-%% Else calculate the Mega difference and add the Secs difference,
-%% note that Secs difference can be negative, e.g.
-%% {827, 999999, 676} diff {828, 1, 653753} == > 2 secs.
-%%
-difference({TimeM, TimeS, _}, {CurM, CurS, _}) when CurM > TimeM ->
- ((CurM - TimeM) * 1000000) + (CurS - TimeS);
-difference({_, TimeS, _}, {_, CurS, _}) ->
- CurS - TimeS.
-
%%% ------------------------------------------------------
%%% Error and progress reporting.
%%% ------------------------------------------------------