aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src/supervisor.erl
diff options
context:
space:
mode:
authorSiri Hansen <[email protected]>2017-10-06 16:05:57 +0200
committerSiri Hansen <[email protected]>2017-11-09 15:15:59 +0100
commit692e502e1df14e4d2b1fc3195d8ab3b9b398c248 (patch)
tree22e66262da1d601dd8c6af3f1bdb8917a6d12269 /lib/stdlib/src/supervisor.erl
parent25594e5f8718648042f22ee508781e8694601eb4 (diff)
downloadotp-692e502e1df14e4d2b1fc3195d8ab3b9b398c248.tar.gz
otp-692e502e1df14e4d2b1fc3195d8ab3b9b398c248.tar.bz2
otp-692e502e1df14e4d2b1fc3195d8ab3b9b398c248.zip
[supervisor] Use map instead of dict for dynamic children
Diffstat (limited to 'lib/stdlib/src/supervisor.erl')
-rw-r--r--lib/stdlib/src/supervisor.erl28
1 files changed, 14 insertions, 14 deletions
diff --git a/lib/stdlib/src/supervisor.erl b/lib/stdlib/src/supervisor.erl
index 839f23c987..e3c23c62c5 100644
--- a/lib/stdlib/src/supervisor.erl
+++ b/lib/stdlib/src/supervisor.erl
@@ -106,7 +106,7 @@
-record(state, {name,
strategy :: strategy() | 'undefined',
children = [] :: [child_rec()],
- dynamics :: {'dict', dict:dict(pid(), list())}
+ dynamics :: {'maps', #{pid() => list()}}
| {'sets', sets:set(pid())}
| 'undefined',
intensity :: non_neg_integer() | 'undefined',
@@ -1355,35 +1355,35 @@ dyn_size(#state{dynamics = {Mod,Db}}) ->
dyn_erase(Pid,#state{dynamics={sets,Db}}=State) ->
State#state{dynamics={sets,sets:del_element(Pid,Db)}};
-dyn_erase(Pid,#state{dynamics={dict,Db}}=State) ->
- State#state{dynamics={dict,dict:erase(Pid,Db)}}.
+dyn_erase(Pid,#state{dynamics={maps,Db}}=State) ->
+ State#state{dynamics={maps,maps:remove(Pid,Db)}}.
dyn_store(Pid,_,#state{dynamics={sets,Db}}=State) ->
State#state{dynamics={sets,sets:add_element(Pid,Db)}};
-dyn_store(Pid,Args,#state{dynamics={dict,Db}}=State) ->
- State#state{dynamics={dict,dict:store(Pid,Args,Db)}}.
+dyn_store(Pid,Args,#state{dynamics={maps,Db}}=State) ->
+ State#state{dynamics={maps,Db#{Pid => Args}}}.
dyn_fold(Fun,Init,#state{dynamics={sets,Db}}) ->
sets:fold(Fun,Init,Db);
-dyn_fold(Fun,Init,#state{dynamics={dict,Db}}) ->
- dict:fold(fun(Pid,_,Acc) -> Fun(Pid,Acc) end, Init, Db).
+dyn_fold(Fun,Init,#state{dynamics={maps,Db}}) ->
+ maps:fold(fun(Pid,_,Acc) -> Fun(Pid,Acc) end, Init, Db).
dyn_map(Fun, #state{dynamics={sets,Db}}) ->
lists:map(Fun, sets:to_list(Db));
-dyn_map(Fun, #state{dynamics={dict,Db}}) ->
- lists:map(Fun, dict:fetch_keys(Db)).
+dyn_map(Fun, #state{dynamics={maps,Db}}) ->
+ lists:map(Fun, maps:keys(Db)).
dyn_exists(Pid, #state{dynamics={sets, Db}}) ->
sets:is_element(Pid, Db);
-dyn_exists(Pid, #state{dynamics={dict, Db}}) ->
- dict:is_key(Pid, Db).
+dyn_exists(Pid, #state{dynamics={maps, Db}}) ->
+ maps:is_key(Pid, Db).
dyn_args(_Pid, #state{dynamics={sets, _Db}}) ->
{ok,undefined};
-dyn_args(Pid, #state{dynamics={dict, Db}}) ->
- dict:find(Pid, Db).
+dyn_args(Pid, #state{dynamics={maps, Db}}) ->
+ maps:find(Pid, Db).
dyn_init(#state{children=[Child]}=State) when ?is_temporary(Child) ->
State#state{dynamics = {sets,sets:new()}};
dyn_init(State) ->
- State#state{dynamics = {dict,dict:new()}}.
+ State#state{dynamics = {maps,#{}}}.