[dmd-concurrency] Sending mesages to non-listening threads

Sean Kelly sean at invisibleduck.org
Tue Jan 12 15:25:18 PST 2010


On Jan 12, 2010, at 2:29 PM, Andrei Alexandrescu wrote:

> Steve Schveighoffer wrote:
> 
>> The other possibility is to only allow so many messages to be queued before the queue is "full".  Unsure what you want to do at that point though, either block or return an EAGAIN type error (maybe you can do both depending on how you want to send the message).  This solution is at least more likely to show logic errors, since with the first solution you may forget to close the handle.  But it also could cause deadlocks or force you to write handling code for full queue conditions.
>> How does erlang handle this?
> 
> I haven't found a mechanism described in the Erlang book. I think good Erlang style is to call receive with an "everything" handler at least in a while.

In Erlang, receiveAny() is just a side effect of the pattern matching:

    receive
        Any ->
            io:format( "got something: ~p", Any );
    end.

I suppose the closest fit in D would be to accept a Variant :-)


More information about the dmd-concurrency mailing list