The current Mailbox implementation in std.concurency uses a private List
struct where every call to .put() needs to allocate a new node from the GC.
A better alternative is a ring buffer which can do all the things the Mailbox needs and faster in every way. The growing time can be compensated by a right call to setMaxMailboxSize() and any random removal can be a swap of the last element with the one being removed.
Forum link: http://forum.dlang.org/thread/[email protected]
Comment #1 by robert.schadek — 2024-12-01T16:22:19Z