|
36 | 36 | %% the pool is configurable, the aim is to make sure we don't have too
|
37 | 37 | %% few delegates and thus limit performance on many-CPU machines.
|
38 | 38 |
|
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. |
46 | 49 | %% 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. |
49 | 52 |
|
50 | 53 | -behaviour(gen_server2).
|
51 | 54 |
|
|
0 commit comments