diff options
author | Matthias Radestock <matthias@rabbitmq.com> | 2011-07-28 13:03:11 +0100 |
---|---|---|
committer | Matthias Radestock <matthias@rabbitmq.com> | 2011-07-28 13:03:11 +0100 |
commit | 99e9d09a4ee6716652f68a4aeedad8e07c385f88 (patch) | |
tree | 58362456adc26170ad459cb40e1eb490496e1ad9 | |
parent | 318d37920c395a11c1a72ac55014d7d84dfadd76 (diff) | |
download | rabbitmq-server-99e9d09a4ee6716652f68a4aeedad8e07c385f88.tar.gz |
refactor: use multiple heads instead of 'case'
-rw-r--r-- | src/gen_server2.erl | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/src/gen_server2.erl b/src/gen_server2.erl index 60471181..dad04fa7 100644 --- a/src/gen_server2.erl +++ b/src/gen_server2.erl @@ -612,27 +612,19 @@ in(Input, GS2State = #gs2_state { prioritise_info = PI, queue = Queue }) -> GS2State #gs2_state { queue = priority_queue:in( Input, PI(Input, GS2State), Queue) }. -process_msg(Msg, - GS2State = #gs2_state { parent = Parent, - name = Name, - debug = Debug }) -> - case Msg of - {system, From, Req} -> - sys:handle_system_msg( - Req, From, Parent, ?MODULE, Debug, - GS2State); - %% gen_server puts Hib on the end as the 7th arg, but that - %% version of the function seems not to be documented so - %% leaving out for now. - {'EXIT', Parent, Reason} -> - terminate(Reason, Msg, GS2State); - _Msg when Debug =:= [] -> - handle_msg(Msg, GS2State); - _Msg -> - Debug1 = sys:handle_debug(Debug, fun print_event/3, - Name, {in, Msg}), - handle_msg(Msg, GS2State #gs2_state { debug = Debug1 }) - end. +process_msg({system, From, Req}, + GS2State = #gs2_state { parent = Parent, debug = Debug }) -> + sys:handle_system_msg(Req, From, Parent, ?MODULE, Debug, GS2State); +process_msg({'EXIT', Parent, Reason} = Msg, + GS2State = #gs2_state { parent = Parent }) -> + %% gen_server puts Hib on the end as the 7th arg, but that version + %% of the fun seems not to be documented so leaving out for now. + terminate(Reason, Msg, GS2State); +process_msg(Msg, GS2State = #gs2_state { debug = [] }) -> + handle_msg(Msg, GS2State); +process_msg(Msg, GS2State = #gs2_state { name = Name, debug = Debug }) -> + Debug1 = sys:handle_debug(Debug, fun print_event/3, Name, {in, Msg}), + handle_msg(Msg, GS2State #gs2_state { debug = Debug1 }). %%% --------------------------------------------------- %%% Send/recive functions |