diff options
author | Rickard Green <[email protected]> | 2014-12-17 22:18:27 +0100 |
---|---|---|
committer | Rickard Green <[email protected]> | 2015-03-20 15:28:53 +0100 |
commit | fbaa0becc787e73fa539e0d497b0d74be27c9534 (patch) | |
tree | c89e004b5e33d51ca07635678415c8dc4e8f2f23 /lib/kernel/src/pg2.erl | |
parent | 1d9350693fe2c4d1d6b2baa504aacd070e023a1a (diff) | |
download | otp-fbaa0becc787e73fa539e0d497b0d74be27c9534.tar.gz otp-fbaa0becc787e73fa539e0d497b0d74be27c9534.tar.bz2 otp-fbaa0becc787e73fa539e0d497b0d74be27c9534.zip |
Replace usage of erlang:now() with usage of new API
Diffstat (limited to 'lib/kernel/src/pg2.erl')
-rw-r--r-- | lib/kernel/src/pg2.erl | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/kernel/src/pg2.erl b/lib/kernel/src/pg2.erl index b562d4ffd2..70d7a75671 100644 --- a/lib/kernel/src/pg2.erl +++ b/lib/kernel/src/pg2.erl @@ -140,19 +140,22 @@ get_closest_pid(Name) -> [Pid] -> Pid; [] -> - {_,_,X} = erlang:now(), case get_members(Name) of [] -> {error, {no_process, Name}}; Members -> - lists:nth((X rem length(Members))+1, Members) + random_element(Members) end; Members when is_list(Members) -> - {_,_,X} = erlang:now(), - lists:nth((X rem length(Members))+1, Members); + random_element(Members); Else -> Else end. +random_element(List) -> + X = abs(erlang:monotonic_time() + bxor erlang:unique_integer()), + lists:nth((X rem length(List)) + 1, List). + %%% %%% Callback functions from gen_server %%% |