diff options
Diffstat (limited to 'testsuite/tests/lib/Concurrent/4876.hs')
-rw-r--r-- | testsuite/tests/lib/Concurrent/4876.hs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/testsuite/tests/lib/Concurrent/4876.hs b/testsuite/tests/lib/Concurrent/4876.hs new file mode 100644 index 0000000000..68c2a871b8 --- /dev/null +++ b/testsuite/tests/lib/Concurrent/4876.hs @@ -0,0 +1,19 @@ +import System.Random +import Control.Concurrent.SampleVar +import Control.Concurrent +import Control.Monad + +produce, consume :: SampleVar Int -> IO () +produce svar = do + b <- isEmptySampleVar svar + if b then writeSampleVar svar 3 else return () + +consume svar = readSampleVar svar >>= print + +main = do + svar <- newEmptySampleVar + m <- newEmptyMVar + forkIO $ consume svar >> putMVar m () + threadDelay 100000 -- 100 ms + produce svar + takeMVar m -- deadlocked before the fix in #4876 |