[erlang-questions] Can Erlang messages be delivered out of order?

Sergey S ad.sergey@REDACTED
Sun Jan 25 02:01:02 CET 2009


Hello.

Does Erlang runtime guarantee that messages will be delivered in
exactly the same order as they were sent?

To illustrate my question I've written a simple example:

%-------------
process_flag(trap_exit, true),
Parent = self(),

spawn_link(fun() ->
                         Parent ! hello,
                         Parent ! world
                 end)

receive hello -> ok end,
receive world -> ok end,
receive {'EXIT', _Pid, normal} -> ok end.
%-------------

Is it guaranteed by the runtime that the 'hello' message will always
be the first message put into mailbox, 'world' - the second one, and
{'EXIT', _Pid, normal} - third?

Thanks.

--
Sergey



More information about the erlang-questions mailing list