[dmd-concurrency] draft 5

Andrei Alexandrescu andrei at erdani.com
Tue Jan 19 22:44:49 PST 2010


Kevin Bealer wrote:
> On Wed, Jan 20, 2010 at 1:28 AM, Andrei Alexandrescu <andrei at erdani.com 
> <mailto:andrei at erdani.com>> wrote:
> 
>     That would certainly work, but honest to God I am completely
>     infatuated with the proposed model. It's simple, no need for a new
>     "daemon" concept, and avoids very easily and elegantly the
>     unpleasant zombie situation when main has finished but is somewhere
>     in limbo mode hoping for some other thread to end.
> 
>     Also, look at how simple it makes all examples. It's a dream come
>     true. I've been thinking of a correct shutdown protocol for years,
>     and this is better than anything I've ever tried.
> 
>     I'd be ok with doing what Java does if we find an Achilles' heel of
>     the current model. If not, I suggest we go with it and let users
>     handle their own daemons (heh) in main().
> 
> 
>     Andrei
> 
> 
> I really like the exception concept, by the way.  But I still think that 
> if there is no way to send normal messages once the shutdown phase 
> begins, you will see a small crop of schemes for sending messages in 
> some other way to coordinate shutdown.  (Moreso on network based systems 
> which tend to have sharper division of 'ownership of role'.)  I've been 
> on a team that had to invent such things ourselves.

I have good news. In the upcoming section "Out-of-Band Communication" I 
will clarify that Shutdown is but one instance of a general oob 
communication mechanism. The mechanism works like this:

* If you pass a message Msg that inherits Exception and the receive() in 
the receiver *handles* Msg, then everything goes normally.

* However, if the receive() call in the receiver does *not* handle Msg 
(or a base of it), then receive() throws the Msg object.

In other words, Exception-derived objects establish an out-of-band, 
priority communication system. If you want to make sure your message 
will be received, you know what to do.

I can't believe exception mesh with this model so well. It's as if they 
were designed for this purpose.


Andrei



More information about the dmd-concurrency mailing list