Why does std.concurrency.Mailbox use lists ?
Sean Kelly via Digitalmars-d
digitalmars-d at puremagic.com
Tue Sep 9 13:52:32 PDT 2014
On Tuesday, 9 September 2014 at 20:47:24 UTC, Sean Kelly wrote:
>
> Incoming messages are appended to the list and removed from the
> middle during receive, so a list seemed like a natural
> representation. This could be optimized by putting a "next" ptr
> inside the Message object itself and make the list literally
> just
> a list of messages instead of a list of nodes referencing
> messages. That would eliminate half of the allocations and not
> have any of the problems that a ring buffer brings with removals
> from the middle or growing the list size.
Oops... I'd forgotten that Message is constructed in-place within
a Node, and so this wouldn't save any allocations. It still
might be a bit of an optimization, but only to save a bit of
copying.
More information about the Digitalmars-d
mailing list