From f78ec0c4bd506f3ec61582b09f38c2a1111dcb89 Mon Sep 17 00:00:00 2001 From: simonm Date: Thu, 8 Oct 1998 11:37:16 +0000 Subject: [PATCH] [project @ 1998-10-08 11:37:15 by simonm] fix conc004 for new type of forkIO. add conc007: killThread test. --- ghc/tests/concurrent/should_run/conc004.hs | 2 +- ghc/tests/concurrent/should_run/conc007.hs | 24 ++++++++++++++++++++++++ ghc/tests/concurrent/should_run/conc007.stdout | 1 + 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 ghc/tests/concurrent/should_run/conc007.hs create mode 100644 ghc/tests/concurrent/should_run/conc007.stdout diff --git a/ghc/tests/concurrent/should_run/conc004.hs b/ghc/tests/concurrent/should_run/conc004.hs index 2580636..246f898 100644 --- a/ghc/tests/concurrent/should_run/conc004.hs +++ b/ghc/tests/concurrent/should_run/conc004.hs @@ -10,7 +10,7 @@ main = do mvar <- newEmptyMVar let - spawner :: (IO () -> IO ()) -> Int -> IO () + spawner :: (IO () -> IO ThreadId) -> Int -> IO () spawner c 0 = putMVar mvar () spawner c n = do { c (spawner c (n-1)); return ()} diff --git a/ghc/tests/concurrent/should_run/conc007.hs b/ghc/tests/concurrent/should_run/conc007.hs new file mode 100644 index 0000000..ccd11be --- /dev/null +++ b/ghc/tests/concurrent/should_run/conc007.hs @@ -0,0 +1,24 @@ +{-# OPTIONS -fglasgow-exts #-} + +module Main where + +import Concurrent +import IOExts + +choose :: a -> a -> IO a +choose a b = do + ready <- newMVar () + answer <- newEmptyMVar + a_id <- forkIO (a `seq` takeMVar ready >> putMVar answer a) + b_id <- forkIO (b `seq` takeMVar ready >> putMVar answer b) + it <- takeMVar answer + killThread a_id + killThread b_id + return it + +main = do + let big = sum [1..] + small = sum [1..42] + test1 <- choose big small + test2 <- choose small big + print (test1,test2) diff --git a/ghc/tests/concurrent/should_run/conc007.stdout b/ghc/tests/concurrent/should_run/conc007.stdout new file mode 100644 index 0000000..ee81b5e --- /dev/null +++ b/ghc/tests/concurrent/should_run/conc007.stdout @@ -0,0 +1 @@ +(903,903) -- 1.7.10.4