diff options
author | Björn Gustavsson <[email protected]> | 2015-12-04 12:15:40 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2015-12-11 14:37:46 +0100 |
commit | 80757f9491c72ee262a5910e0b3b02e95b1e5f2a (patch) | |
tree | 1019a6da73ac28571a0b51727ed6fa33daf11522 /lib/kernel/src/global.erl | |
parent | dee396ffd32dcd68c47cab983c75ba32f921b9db (diff) | |
download | otp-80757f9491c72ee262a5910e0b3b02e95b1e5f2a.tar.gz otp-80757f9491c72ee262a5910e0b3b02e95b1e5f2a.tar.bz2 otp-80757f9491c72ee262a5910e0b3b02e95b1e5f2a.zip |
Use 'rand' instead of the obsolete 'random' module
In most cases, we don't have to seed the random number generator,
as the rand:uniform/1 takes care about that itself.
Diffstat (limited to 'lib/kernel/src/global.erl')
-rw-r--r-- | lib/kernel/src/global.erl | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/lib/kernel/src/global.erl b/lib/kernel/src/global.erl index dcabeb5e49..0c73ead7c5 100644 --- a/lib/kernel/src/global.erl +++ b/lib/kernel/src/global.erl @@ -2068,23 +2068,17 @@ get_known() -> gen_server:call(global_name_server, get_known, infinity). random_sleep(Times) -> - case (Times rem 10) of - 0 -> erase(random_seed); - _ -> ok - end, - case get(random_seed) of - undefined -> - _ = random:seed(erlang:phash2([erlang:node()]), - erlang:monotonic_time(), - erlang:unique_integer()), - ok; - _ -> ok - end, + _ = case Times rem 10 of + 0 -> + _ = rand:seed(exsplus); + _ -> + ok + end, %% First time 1/4 seconds, then doubling each time up to 8 seconds max. Tmax = if Times > 5 -> 8000; true -> ((1 bsl Times) * 1000) div 8 end, - T = random:uniform(Tmax), + T = rand:uniform(Tmax), ?trace({random_sleep, {me,self()}, {times,Times}, {t,T}, {tmax,Tmax}}), receive after T -> ok end. |