Commit dab0c2ed authored by simonmar's avatar simonmar
Browse files

[project @ 2005-05-13 08:15:50 by simonmar]

make this test slightly more robust
parent 948e39c2
module Main where module Main where
import Control.Concurrent import Control.Concurrent
import Control.Exception
import Prelude hiding (catch)
import Foreign
import System.IO
foreign import "sleep" unsafe sleepBlock :: Int -> IO () foreign import "sleep" unsafe sleepBlock :: Int -> IO ()
main :: IO () main :: IO ()
main = do main = do
newStablePtr stdout -- prevent stdout being finalized, sigh
th <- newEmptyMVar th <- newEmptyMVar
forkIO $ do forkIO $ do
putStrLn "newThread started" putStrLn "newThread started"
sleepBlock 3 sleepBlock 1
putStrLn "newThread back again" putMVar th "child"
putMVar th "5 secs later" threadDelay 500000 >> putMVar th "main" `catch` \_ -> return ()
threadDelay 1000000 >> putStrLn "mainThread"
-- tests that the other thread doing an unsafe call to -- tests that the other thread doing an unsafe call to
-- sleep(3) has blocked this thread. Not sure if this -- sleep(3) has blocked this thread. Not sure if this
-- is a useful test. -- is a useful test.
......
newThread started newThread started
newThread back again child
mainThread
5 secs later
shutting down shutting down
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