November 17, 2011
I've had this bug recently:

auto workTid = spawn(&work);
setMaxMailboxSize(thisTid, 1, OnCrowding.throwException);

IOW, I've passed 'thisTid' instead of 'workTid' to the call.

Is there any reason why had to be a global function? Tid has a private MessageBox which has the setMaxMsgs method. We can't really call this method directly via "tid.mbox.setMaxMsgs" since it's private, but a forwarding function could be put inside of Tid:

struct Tid {
    void setMaxMailboxSize( Tid tid, size_t messages, OnCrowding doThis )
    {
        final switch( doThis )
        {
        case OnCrowding.block:
            return mbox.setMaxMsgs( messages, &onCrowdingBlock );
        case OnCrowding.throwException:
            return mbox.setMaxMsgs( messages, &onCrowdingThrow );
        case OnCrowding.ignore:
            return mbox.setMaxMsgs( messages, &onCrowdingIgnore );
        }
    }

    // ...
}

Of course the global function would have to be kept for compatibility..

Btw, MessageBox is ddoc documented, but nothing outside of std.concurrency can call any of its methods and the class itself is private. That seems kind of strange.. If it's not intended to be subclassed it could be marked with final as well, no?

Also, it would be cool if I could read the m_localMsgs field, just to inspect if there are any messages left without doing a blocking call or popping any messages off the queue.