[Haskell-cafe] Re: Cleaning up threads
mmitar at gmail.com
Tue Sep 14 20:40:22 EDT 2010
On Wed, Sep 15, 2010 at 2:16 AM, Ertugrul Soeylemez <es at ertes.de> wrote:
> The point is that killThread throws an exception. An exception is
> usually an error condition.
This is reasoning based on nomenclature. If exceptions were named
"Signal" or "Interrupt"?
> My approach strictly separates an unexpected crash from an intended quit.
For this you can have multiple types of exceptions, some which signify
error condition and some which signify that user has "interrupted" a
process and that process should gracefully (exceptionally) quit.
I like exceptions because you can split main logic from "exceptional"
logic (like user wants to prematurely stop the program). But you still
want to clean up properly everything. Once you have this "exceptional"
logic in place (and you should always have it as some exceptional
things can always happen) why do not use it also for less exceptional
things (because you have cleaner code then).
> Also using the Quit command from my example you can actually wait for
> the thread to finish cleanup work. You can't do this with an exception.
You can. If you would have a proper way to mask them:
More information about the Haskell-Cafe