summaryrefslogtreecommitdiff
path: root/lifted-concurrent/test/TestThreads.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lifted-concurrent/test/TestThreads.hs')
-rw-r--r--lifted-concurrent/test/TestThreads.hs21
1 files changed, 21 insertions, 0 deletions
diff --git a/lifted-concurrent/test/TestThreads.hs b/lifted-concurrent/test/TestThreads.hs
new file mode 100644
index 00000000..8360badb
--- /dev/null
+++ b/lifted-concurrent/test/TestThreads.hs
@@ -0,0 +1,21 @@
1import Control.Monad
2import Control.Exception (throwIO)
3
4import Control.Concurrent.ThreadUtil
5import DebugUtil
6
7main = do
8 mvars <- sequence $ replicate 200 $ newEmptyMVar
9 threads <- forM mvars $ forkIO . join . takeMVar
10 let (normalquits,mvars1) = splitAt 20 mvars
11 mapM_ (`putMVar` return ()) normalquits
12 let (exceptionquits,mvars2) = splitAt 20 mvars1
13 mapM_ (`putMVar` throwIO (userError "oops")) exceptionquits
14 let (throwtoexceptions,threads1) = splitAt 20 $ drop 40 threads
15 mapM_ (`throwTo` userError "throwTo-oops") throwtoexceptions
16 let (killed,threads2) = splitAt 20 threads1
17 mapM_ killThread killed
18 threadDelay 1000000
19 report <- threadReport True
20 sequence_ $ zipWith (\n s -> putStrLn $ unwords [show n,s]) [1..] $ lines report
21 return ()