aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src/gen_event.erl
diff options
context:
space:
mode:
authorGustav Simonsson <[email protected]>2012-02-24 14:51:48 +0100
committerGustav Simonsson <[email protected]>2012-02-24 14:51:55 +0100
commitd9ee75fa3df8676deb92136c38b65e928cde196e (patch)
tree3fa69ad981703294dc4b2e307aaae4ddfb38918d /lib/stdlib/src/gen_event.erl
parentdbb30ebf60fc9e851f1a8d9c0970ec2a2cc88f57 (diff)
parentb0426732cc19598f0c0c310b1e79918252495259 (diff)
downloadotp-d9ee75fa3df8676deb92136c38b65e928cde196e.tar.gz
otp-d9ee75fa3df8676deb92136c38b65e928cde196e.tar.bz2
otp-d9ee75fa3df8676deb92136c38b65e928cde196e.zip
Merge branch 'uw/extending_gen' into maint
* uw/extending_gen: Add plugin support for alternative name lookup OTP-9945
Diffstat (limited to 'lib/stdlib/src/gen_event.erl')
-rw-r--r--lib/stdlib/src/gen_event.erl10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/stdlib/src/gen_event.erl b/lib/stdlib/src/gen_event.erl
index 3317b30e5c..ca05df20c0 100644
--- a/lib/stdlib/src/gen_event.erl
+++ b/lib/stdlib/src/gen_event.erl
@@ -107,8 +107,10 @@
-type add_handler_ret() :: ok | term() | {'EXIT',term()}.
-type del_handler_ret() :: ok | term() | {'EXIT',term()}.
--type emgr_name() :: {'local', atom()} | {'global', atom()}.
--type emgr_ref() :: atom() | {atom(), atom()} | {'global', atom()} | pid().
+-type emgr_name() :: {'local', atom()} | {'global', atom()}
+ | {'via', atom(), term()}.
+-type emgr_ref() :: atom() | {atom(), atom()} | {'global', atom()}
+ | {'via', atom(), term()} | pid().
-type start_ret() :: {'ok', pid()} | {'error', term()}.
%%---------------------------------------------------------------------------
@@ -143,6 +145,7 @@ init_it(Starter, Parent, Name0, _, _, Options) ->
name({local,Name}) -> Name;
name({global,Name}) -> Name;
+name({via,_, Name}) -> Name;
name(Pid) when is_pid(Pid) -> Pid.
-spec add_handler(emgr_ref(), handler(), term()) -> term().
@@ -209,6 +212,9 @@ call1(M, Handler, Query, Timeout) ->
send({global, Name}, Cmd) ->
catch global:send(Name, Cmd),
ok;
+send({via, Mod, Name}, Cmd) ->
+ catch Mod:send(Name, Cmd),
+ ok;
send(M, Cmd) ->
M ! Cmd,
ok.