darcs patch: forkChild, waitForChild, parIO, timeout

Simon Marlow simonmarhaskell at gmail.com
Thu Nov 9 04:31:13 EST 2006

Taral wrote:
> On 11/8/06, Simon Marlow <simonmarhaskell at gmail.com> wrote:
>> Nearly - but this one doesn't nest.  Also, it's possible for the Timeout
>> exception to leak.
> Okay, nesting could be covered by changing Timeout to Timeout Unique
> (or something else equivalent). The exception leaking is impossible to
> avoid so long as the application can catch arbitrary exceptions.

Actually I was mistaken about the leaking exception - I misread the code as 
having the catchDyn inside the bracket rather than outside.

I'm not worried about the programmer being able to catch the Timeout exception, 
that's just a case of "don't do that".

So we have two versions:

   - Peter Simon's version, which nests but requires an extra thread
     per timeout and doesn't propagate exceptions from the main thread
     to the child.

   - Your version, which doesn't nest but does behave nicely with
     respect to exceptions delivered from outside.

If you can modify your version to nest properly, I think it's a winner.  The 
ideal unique value to use is the ThreadId of the timeout thread.


More information about the Libraries mailing list