On Thu, Apr 8, 2010 at 9:15 PM, Isaac Dupree
<m...@isaac.cedarswampstudios.org> wrote:
> I still would like to see examples of where it's needed, because I slightly
> suspect that wrapping possibly-blocking operations in an exception handler
> that does something appropriate, along with ordinary 'mask', might be
> sufficient... But I expect to be proved wrong; I just haven't figured out
> how to prove myself wrong.

Take my threads package, I uploaded to hackage yesterday, as an example.

In Control.Concurrent.Thread.Group.fork I first increment numThreads
before forking. When the fork thread terminates it should decrement
numThreads and release the lock when it reaches zero so that potential
waiters are woken up:

http://hackage.haskell.org/packages/archive/threads/0.1/doc/html/src/Control-Concurrent-Thread-Group.html#fork

Now if an asynchronous exception is thrown during the takeMVar in
decrement there's no way I can prevent not releasing the lock causing
the waiters to deadlock.

This could be solved by wrapping decrement in nonInterruptibleMask.

regards,

Bas
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to