Why does std.concurrency.Mailbox use lists ?

via Digitalmars-d digitalmars-d at puremagic.com
Wed Sep 10 04:11:06 PDT 2014


On Tuesday, 9 September 2014 at 22:34:09 UTC, Sean Kelly wrote:
> On Monday, 8 September 2014 at 17:24:53 UTC, Marc Schütz wrote:
>>
>> AFAICS, the documentation doesn't write about any ordering 
>> guarantees of messages, but I can imagine that there are 
>> implicit expectations. In particular prioritySend() could 
>> break, if the implementation isn't done carefully.
>
> The actor model imposes no requirement on the order of received
> messages.  However, I want to try and guarantee that messages
> will be received from a given sender in the order that they were
> sent.  I think this is a much easier model to code to, and it's
> what people expect.

This example from Andrei's TDPL certainly depends on it:
http://www.informit.com/articles/article.aspx?p=1609144&seqNum=7

It would be much more difficult to implement without an ordering 
guarantee.

> It may be that at some point in the future
> for some desirable communication protocol it will not be 
> possible
> to make this guarantee, but in that case the people who choose 
> to
> use that protocol can make an informed decision concerning the
> tradeoffs.

UDP comes to mind; it is neither reliable nor guarantees ordering.

I think there should be an explicit guarantee for those protocols 
that can provide it. Otherwise it would just be an implementation 
detail that cannot be relied upon, and people always have to 
assume the worst.


More information about the Digitalmars-d mailing list