Skip to content

Commit dfa730b

Browse files
delegate: documentation edits
1 parent 202f881 commit dfa730b

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

deps/rabbit_common/src/delegate.erl

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,19 @@
3636
%% the pool is configurable, the aim is to make sure we don't have too
3737
%% few delegates and thus limit performance on many-CPU machines.
3838

39-
%% Optimisation for 'delegate'
40-
%% If a message is sent to only one queue(in most application scenarios),
41-
%% passing through the 'delegate' is meaningless.
42-
%% Hardcoding "?DEFAULT_NAME and/or gen_server2" is to avoid affecting those
43-
%% operations that must go through the 'delegate', such as:
44-
%% 1. "delegate:invoke(Pids, {erlang, process_info, [memory]})", "erlang, process_info"
45-
%% must be called inside the target node.
39+
%% There are some optimisations applied.
40+
%% If a message is sent to only one queue (a common scenario),
41+
%% sending them over the delegate mechanism is redundant.
42+
%% This optimization is applied to gen_server2 module calls when
43+
%% delegate prefix matches the default, ?DEFAULT_NAME.
44+
%%
45+
%% Coonsider two examples:
46+
%%
47+
%% 1. "delegate:invoke(Pids, {erlang, process_info, [memory]})", "erlang:process_info/1"
48+
%% should be called inside the target node.
4649
%% 2. "{Results, Errors} = delegate:invoke(MemberPids, ?DELEGATE_PREFIX, FunOrMFA)",
47-
%% For some reason, the operation specifically specifies a delegate name rather than
48-
%% ?DEFAULT_NAME.
50+
%% Since this operation specifically specifies a delegate name rather than
51+
%% relying on ?DEFAULT_NAME, it will be invoked using the delegate mechanism.
4952

5053
-behaviour(gen_server2).
5154

0 commit comments

Comments
 (0)