Concurrent Haskell, asynchronous exceptions and interruptibility (again)

For Concurrent Haskell, with respect to asynchronous exceptions, can a thread receive an asynchronous exception if it's evaluating an expression that could "potentially block on IO" when evaluated within the "block" function? Specifically, is interruptibility determined statically in the language definition or dynamically at run time? For example, assume a thread is evaluating the following function. transfer :: MVar a -> IO (MVar a) transfer from = block $ do to <- newEmptyMVar x <- takeMVar from putMVar to x return to In general, since putMVar is an IO function, it can potentially block (if its MVar argument is already occupied with a value). However, since "MVar to" will obviously be vacant in this instance, the putMVar can not block on IO. Would ghc allow an asynchronous exception to be raised at the point that "putMVar to x" is evaluated? If not, then I guess transfer is exception safe. Would that answer scale? Could I replace the "putMVar to x" with an arbitrarily large/complex IO function that I might write that is guaranteed (by me at least) to be non-blocking and still be sure that an exception would not be delivered during evaluation of that function? Cheers, Patrick. _________________________________________________________________ Internet access plans that fit your lifestyle -- join MSN. http://resourcecenter.msn.com/access/plans/default.asp
participants (1)
-
Patrick Bosworth