
12 Apr
2009
12 Apr
'09
5:23 p.m.
Felipe Lessa wrote:
writeSampleVar :: SampleVar a -> a -> IO () writeSampleVar s x = block $ withMVar (svLock s) $ const $ do tryTakeMVar (svData s) putMVar (svData s) x
withMVar is a blocking operation, thus interruptible despite 'block', I believe... perhaps moving the block inward might more clearly specify what happens (and be *at least* as correct, maybe more correct?) : writeSampleVar s x = withMVar (svLock s) $ const $ block $ do tryTakeMVar (svData s) --nonblocking, thus not exception-interruptible putMVar (svData s) x --because the lock is taken and the MVar emptied, -- this is guaranteed to succeed and not to block -Isaac