[dmd-concurrency] shutting down

Sean Kelly sean at invisibleduck.org
Wed Jan 20 15:20:53 PST 2010


On Jan 20, 2010, at 1:00 PM, Andrei Alexandrescu wrote:

> Michel Fortin wrote:
>> Le 2010-01-20 à 15:24, Andrei Alexandrescu a écrit :
>>> I think threads shouldn't be able to do much during shutdown. For example I don't think they should suddenly open sockets. How about opening files? Or calling system()? Any ideas on a unified approach?
>> Why do you think that?
> 
> I'm thinking, there are too many programs that hang when I want to end them just because some thread inside is waiting for a socket. I think that any operation that could block for an arbitrary amount of time should be disallowed during shutdown.

What if the program is logging to a remote host and wants to log a shutdown event?

> What sockets library do today is, they offer a global close_library function. Once that is called, all pending socket connections and all new socket connections fail immediately.

If it helps, here is the current process shutdown behavior:

1. join all non-daemon threads (non-daemon is the default)
2. set Runtime.isHalting to true
3. call module dtors
4. cleanup and exit

What's missing here is that daemon threads are forcibly terminated when the process exits, while following the shotdown approach there should be a step 3a that causes messaging to throw, etc.  Instead of setting an isDaemon flag in user code, some other means could be used.  Perhaps calling detach() on a Tid makes the thread a daemon thread?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/dmd-concurrency/attachments/20100120/0f0cd2d0/attachment.htm>


More information about the dmd-concurrency mailing list