[erlang-questions] order-preserving send?
Thu Aug 28 15:56:39 CEST 2008
Matthias Lang wrote:
> On Wednesday, August 27, atomly wrote:
>> [Bill McKeeman <Bill.McKeeman@REDACTED>]
>>> Simple newbie question. Suppose I have a process id U, and send two
>>> U ! Message1.
>>> U ! Message2.
>>> Is there a guarantee that the messages will be received in the order
>>> they were sent?
>> No. There's not even a guarantee that both (or either) messages will be
> That misleading and, for practical purposes, wrong.
>>From the FAQ:
> | 10.9 Is the order of message reception guaranteed?
> | Yes, but only within one process.
> | If there is a live process and you send it message A and then message
> | B, it's guaranteed that if message B arrived, message A arrived before
> | it.
That is however not true (in the distributed case), it is possible to
drop A and then later receive B. The paper 'Programming Distributed
Erlang Applications: Pitfalls and Recipes' describes this situation as
well as some other quirks:
> | On the other hand, imagine processes P, Q and R. P sends message A to
> | Q, and then message B to R. There is no guarantee that A arrives
> | before B. (Distributed Erlang would have a pretty tough time if this
> | was required!)
That is actually guaranteed in the local (non-distributed) case, then A
is actually *always* delivered before B. But as mentioned it doesn't
hold in the distributed setting.
> The next question is also relevant:
More information about the erlang-questions