[dmd-concurrency] Sending mesages to non-listening threads
Michel Fortin
michel.fortin at michelf.com
Tue Jan 12 15:12:47 PST 2010
Le 2010-01-12 à 17:26, Andrei Alexandrescu a écrit :
> Michel Fortin wrote:
>> It's nice that you can now send messages to any thread like this:
>> tid.send(i);
>> But... what if you're sending a message to the wrong thread, to a thread that isn't listening for messages? Do the messages accumulate in memory until no memory is left? If that's the case, sending messages to the wrong thread would become a memory leak. Any solution?
>
> I think mailbox crowding is a liability of message-passing systems in general. We can mitigate that in a number of ways, including an API for threads to set a ceiling for their mailbox:
>
> enum OnCrowding { wait, throwException }
> setMaxMailboxSize(size_t messages, OnCrowding doThis);
Looks like a fine solution, but I'm wary of the crowding policies you propose because it forces message passing to be somewhat synchronous: if you're on a network you must wait for the reply in case you need to throw an exception. It's very appropriate for thread-to-thread though, so I'm not sure what to propose.
--
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/
More information about the dmd-concurrency
mailing list