[dmd-concurrency] Shutdown protocol

Michel Fortin michel.fortin at michelf.com
Thu Jan 21 04:22:24 PST 2010


Le 2010-01-21 à 3:14, Andrei Alexandrescu a écrit :

>> So lets say that threads will normally fall into the three camps, that I'll call producers, filters and processors.
> [snip]
>> Main could check if it has any dependents, if desired... (these last bits is kind of off the cuff, so maybe there are huge problems with them.)
> 
> This makes sense, but at this point I'd avoid classifications that don't have a precedent. If Erlang made it without thread kinds, we should too.

Erlang has the notion of links between threads (or should I say process?). If you link thread B to thread A, when thread A completes thread B receives a message to that effect. The default action is to do nothing if thread A exited normally and abort if thread A exited abnormally. But of course thread B can handle the message differently.

When you think about it, it's pretty much what I proposed we do at the beginning of this thread. The difference were that I was proposing threads to be linked automatically with spawn (erlang use spawn_linked for this) and that threads get a shutdown message automatically when the owner thread terminates, terminating the thread by default (erlang only do this for abnormal termination, although you can change that behaviour in the linked thread's message handler).

I'm no expert on erlang, but that's what I understood from what I read (and cited on this list) yesterday.

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/





More information about the dmd-concurrency mailing list