Broken beyond repair: Control.Concurrent.SampleVar
haskell at list.mightyreason.com
Sun Apr 12 12:12:15 EDT 2009
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
More information about the Libraries