diff options
| author | Matthias Radestock <matthias@rabbitmq.com> | 2012-12-03 13:51:43 +0000 |
|---|---|---|
| committer | Matthias Radestock <matthias@rabbitmq.com> | 2012-12-03 13:51:43 +0000 |
| commit | 9cafb938e6f0566f324570a08751f33c79338b68 (patch) | |
| tree | acd87d22f133078f0383e2e993029ae1cef2681a /src/delegate.erl | |
| parent | 490accde112e4f6946705d33507b5e8af46bd358 (diff) | |
| download | rabbitmq-server-git-9cafb938e6f0566f324570a08751f33c79338b68.tar.gz | |
move generic cross-node funs from rabbit_amqqueue to delegate
since the latter changes less frequently
Diffstat (limited to 'src/delegate.erl')
| -rw-r--r-- | src/delegate.erl | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/delegate.erl b/src/delegate.erl index d595e4819e..9222c34c42 100644 --- a/src/delegate.erl +++ b/src/delegate.erl @@ -18,7 +18,7 @@ -behaviour(gen_server2). --export([start_link/1, invoke_no_result/2, invoke/2]). +-export([start_link/1, invoke_no_result/2, invoke/2, call/2, cast/2]). -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). @@ -35,6 +35,10 @@ [{pid(), term()}]}). -spec(invoke_no_result/2 :: (pid() | [pid()], fun ((pid()) -> any())) -> 'ok'). +-spec(call/2 :: + ( pid(), any()) -> any(); + ([pid()], any()) -> {[{pid(), any()}], [{pid(), term()}]}). +-spec(cast/2 :: (pid() | [pid()], any()) -> 'ok'). -endif. @@ -96,6 +100,12 @@ invoke_no_result(Pids, Fun) when is_list(Pids) -> safe_invoke(LocalPids, Fun), %% must not die ok. +call(PidOrPids, Msg) -> + invoke(PidOrPids, fun (P) -> gen_server2:call(P, Msg, infinity) end). + +cast(PidOrPids, Msg) -> + invoke_no_result(PidOrPids, fun (P) -> gen_server2:cast(P, Msg) end). + %%---------------------------------------------------------------------------- group_pids_by_node(Pids) -> |
