From 0bf2fdab482da7a287ef09f18e7656abe62256d0 Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Tue, 20 Jul 2010 15:38:58 +0000 Subject: [PATCH] add numSparks :: IO Int (#4167) --- GHC/Conc.lhs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/GHC/Conc.lhs b/GHC/Conc.lhs index d676a1a..0d17457 100644 --- a/GHC/Conc.lhs +++ b/GHC/Conc.lhs @@ -33,6 +33,7 @@ module GHC.Conc , forkOnIO -- :: Int -> IO a -> IO ThreadId , forkOnIOUnmasked , numCapabilities -- :: Int + , numSparks -- :: IO Int , childHandler -- :: Exception -> IO () , myThreadId -- :: IO ThreadId , killThread -- :: ThreadId -> IO () @@ -265,6 +266,10 @@ numCapabilities = unsafePerformIO $ do n <- peek n_capabilities return (fromIntegral n) +-- | Returns the number of sparks currently in the local spark pool +numSparks :: IO Int +numSparks = IO $ \s -> case numSparks# s of (# s', n #) -> (# s', I# n #) + #if defined(mingw32_HOST_OS) && defined(__PIC__) foreign import ccall "_imp__n_capabilities" n_capabilities :: Ptr CInt #else -- 1.7.10.4