From c19f3a54cf37d8af27c0abae6b01c452a38a3534 Mon Sep 17 00:00:00 2001 From: David Terei Date: Thu, 29 Mar 2012 16:15:51 -0700 Subject: [PATCH] Fix callback001 --- smp/callback001/Main.hs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/smp/callback001/Main.hs b/smp/callback001/Main.hs index 493fd0f..31f4cdd 100644 --- a/smp/callback001/Main.hs +++ b/smp/callback001/Main.hs @@ -13,27 +13,27 @@ module Main where import Control.Concurrent import Control.Monad -import Foreign.Ptr import Data.IORef +import Foreign.Ptr import System.Environment import System.IO main = do [s] <- getArgs - let n = read s :: Int + let n = read s :: Int + fork = if rtsSupportsBoundThreads then forkOS else forkIO sem <- newQSemN 0 - let fork = if rtsSupportsBoundThreads then forkOS else forkIO - replicateM n (putStr "." >> hFlush stdout >> fork (thread sem) >> thread sem) + replicateM n $ putStr "." >> hFlush stdout >> fork (thread sem) >> thread sem + putChar '\n' waitQSemN sem (n*2) - thread sem = do var <- newIORef 0 let f = modifyIORef var (1+) callC =<< mkFunc f signalQSemN sem 1 -type FUNC = IO () +type FUNC = IO () foreign import ccall unsafe "wrapper" mkFunc :: FUNC -> IO (FunPtr FUNC) -- GitLab