[erlang-questions] Message send guarantees

Lukas Larsson lukas@REDACTED
Wed Jan 25 09:37:27 CET 2017


On Wed, Jan 25, 2017 at 12:38 AM, Dmitry Kakurin <dima_kakurin@REDACTED>

> When I execute "pid ! msg" and it returns, what are the guarantees if pid
> and self are on the same node?
> Can I assume that by the time it returns, msg is in the pid's queue? And
> as a result all messages sent to pid afterwards will be queued after msg?

No you cannot assume that. The message is considered "in transit" until the
receiving process inspects it somehow.

> The reason I'm asking is because I need a guarantee of proper message
> ordering in the following scenario when all processes involved are local to
> a node:
> 1. A --msg1--> C (process A sends msg1 to process C)
> 2. A --msg2--> B
> 3. B --msg2--> C (process B simply proxies msg2 from A to C)
> I need a guarantee that msg2 will always appear in C's queue after msg1.

You have to do this using messages or some other sync mechanism.

> P.S. I've read the FAQ 10.8 and 10.9 :-)

Please add to the FAQ if you think that you can make it clearer on this
point. https://github.com/matthiasl/Erlang-FAQ

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20170125/6415cd3b/attachment.htm>

More information about the erlang-questions mailing list