[Haskell-cafe] Re: Cleaning up threads

David Leimbach leimy2k at gmail.com
Tue Sep 14 20:51:57 EDT 2010

On Tue, Sep 14, 2010 at 11:29 AM, Bryan O'Sullivan <bos at serpentine.com>wrote:

> On Tue, Sep 14, 2010 at 11:21 AM, Edward Z. Yang <ezyang at mit.edu> wrote:
>> Pure code can always be safely asynchronously interrupted (even code
>> using state like the ST monad), and IO code can be made to interact
>> correctly with thread termination simply by using appropriate bracketing
>> functions that would handle normal IO exceptions.
> Ertugrul's advice is still correct. I'd wager there are very few concurrent
> applications that could survive a killThread without disaster. People simply
> don't write or test code with that in mind, and even when they do, it's more
> likely than not to be wrong.

I don't use killThread, and I write what I'd call somewhat complex
concurrent Haskell software for a living right now :-).

Instead I have a TChan of commands that I can send to a thread, either from
the outside or inside, and that thread will eventually come back to it's
event loop that looks at such messages, and shut down gracefully from there.

Of course the only time this would happen is if something goes wrong and I'm
going to restart and forget all the data I have accumulated thus far anyway.

> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100914/e0f4ef33/attachment.html

More information about the Haskell-Cafe mailing list