Commit da6cae40 authored by Simon Marlow's avatar Simon Marlow
Browse files

add test for threadStatus

parent fa25624d
......@@ -11,6 +11,9 @@ test('conc006', normal, compile_and_run, [''])
test('conc027', normal, compile_and_run, [''])
test('conc051', normal, compile_and_run, [''])
test('conc069', only_ways(['ghci','threaded1','threaded2']), compile_and_run, [''])
# this test gives slightly different results for non-threaded ways, so omit
# those for now.
test('conc070', only_ways(['ghci','threaded1','threaded2']), compile_and_run, [''])
# -----------------------------------------------------------------------------
# These tests we only do for a full run
......
import Control.Concurrent
import GHC.Conc
import Data.List
import Data.Maybe
main = do
t1 <- forkIO (threadDelay 100000000)
m <- newEmptyMVar
t2 <- forkIO (takeMVar m)
t3 <- forkIO (let loop = do r <- tryTakeMVar m;
_ <- newEmptyMVar -- do some allocation :(
if isNothing r then loop else return ()
in loop)
t4 <- forkIO (return ())
yield
threadDelay 10000
print =<< mapM threadStatus [t1,t2,t3,t4]
putMVar m ()
[ThreadBlocked BlockedOnMVar,ThreadBlocked BlockedOnMVar,ThreadRunning,ThreadFinished]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment