[erlang-questions] gen_server cast question

Per Hedeland <>
Thu Feb 1 00:25:10 CET 2007


"Ulf Wiger" <> wrote:
>
>Den 2007-01-31 17:20:33 skrev Logan, Martin <>:
>
>> Message order is not guaranteed with asynchronous messaging in any case.
>> You should never rely on it.  Also, as an aside, it would be strange to
>> have a reference to a process for a node that is not connected, that
>> suggests poor design.
>
>In Barklund's formal semantics for Erlang
>(http://citeseer.ist.psu.edu/fredlund01framework.html)
>
>the following is stated:
>
>"The semantics communication (rule com) is such that if two consecutive  
>messages m1 and m2 are sent by process p1 to process
>p2 then message m1 will always arrive before message m2."

AFAIK this describes the semantics of '!' (a.k.a. erlang:send/2), wich
is part of the language.

>I'm not sure where else it is defined, but I'm pretty sure that you can  
>rely on this being true.

For '!', yes. The original question was about gen_server:cast/2, which
is a library function that can do whatever it pleases, at least as long
as it is documented. Unfortunately the man page doesn't say anything
about the arrival order of requests, but at least that means that it
doesn't explicitly guarantee that requests will arrive in the order they
are sent.:-)

I guess it would be reasonable to assume that it has the same semantics
as '!' in this respect - then again, if you want those semantics, you
can of course use '!' to send to a gen_server too...

--Per Hedeland



More information about the erlang-questions mailing list