[erlang-patches] Selectively receive system messages in gen_server and gen_fsm

Jesper Louis Andersen jesper.louis.andersen@REDACTED
Mon Jan 7 19:03:07 CET 2013


On Mon, Jan 7, 2013 at 6:02 PM, Pedram Nimreezi <mc@REDACTED>wrote:

> - When you say catch all, does that mean the first pattern matches are
> irrelevant for selective receive if the last match is a catch all,
> does this implicitly invalidate the selective receive optimization?
>

Suppose you have patterns P1 and P2 and Messages M1 and M2 in that order in
the mailbox and receive clause. Let PmM mean match pattern P against
message M. Now two orders are possible:

A:
P1mM1
P2mM1
P1mM2
P2mM2

and B:
P1mM1
P1mM2
P2mM1
P2mM2

Erlang uses A as the match style, so if P1 or P2 is a catch all, M1 will
always be picked before M2. Had Elrang used match style B then the order
would matter, but it doesn't.



-- 
J.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-patches/attachments/20130107/b4b99b22/attachment.htm>


More information about the erlang-patches mailing list