
12 Apr
2009
12 Apr
'09
12:12 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
That is obvious, but 'block $' is not atomic. Threads 1 and 2 get past the tryTakeMVar. Then thread 1 succeeds with putMVar and thread 2 blocks. Thread 2 is not supposed to block, so this is a failure to agree with the specification.