aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/src
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2012-09-14 12:25:13 +0200
committerBjörn Gustavsson <[email protected]>2012-09-17 14:25:10 +0200
commit9d1203d2ad5904529754e5e889fe37f8d229ad4c (patch)
treef039e3ac4c3ceff371598e0e5762d81631f3d379 /lib/kernel/src
parentf2230a865e269c468192fa582b1c44fc60ffd5fc (diff)
downloadotp-9d1203d2ad5904529754e5e889fe37f8d229ad4c.tar.gz
otp-9d1203d2ad5904529754e5e889fe37f8d229ad4c.tar.bz2
otp-9d1203d2ad5904529754e5e889fe37f8d229ad4c.zip
global: Allow "tuple funs" as resolve functions
Commit de7e01c958ff7c9e6da4034a53567a30a4ae5792 removed support for tuple funs. To still allow resolve functions for global:{re_}register_name/3 to be specified as {M,F}, we'll need to translate {M,F} to an external fun. Also update the documentation to mention that the use of {M,F} to specify a resolve function is deprecated, and to add a recommendation to use an external fun.
Diffstat (limited to 'lib/kernel/src')
-rw-r--r--lib/kernel/src/global.erl12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/kernel/src/global.erl b/lib/kernel/src/global.erl
index 36cb713ee1..b24a9d5eac 100644
--- a/lib/kernel/src/global.erl
+++ b/lib/kernel/src/global.erl
@@ -232,7 +232,8 @@ register_name(Name, Pid) when is_pid(Pid) ->
Name :: term(),
Pid :: pid(),
Resolve :: method().
-register_name(Name, Pid, Method) when is_pid(Pid) ->
+register_name(Name, Pid, Method0) when is_pid(Pid) ->
+ Method = allow_tuple_fun(Method0),
Fun = fun(Nodes) ->
case (where(Name) =:= undefined) andalso check_dupname(Name, Pid) of
true ->
@@ -290,7 +291,8 @@ re_register_name(Name, Pid) when is_pid(Pid) ->
Name :: term(),
Pid :: pid(),
Resolve :: method().
-re_register_name(Name, Pid, Method) when is_pid(Pid) ->
+re_register_name(Name, Pid, Method0) when is_pid(Pid) ->
+ Method = allow_tuple_fun(Method0),
Fun = fun(Nodes) ->
gen_server:multi_call(Nodes,
global_name_server,
@@ -2218,3 +2220,9 @@ intersection(_, []) ->
[];
intersection(L1, L2) ->
L1 -- (L1 -- L2).
+
+%% Support legacy tuple funs as resolve functions.
+allow_tuple_fun({M, F}) when is_atom(M), is_atom(F) ->
+ fun M:F/3;
+allow_tuple_fun(Fun) when is_function(Fun, 3) ->
+ Fun.