[commit: base] master: Add getNumProcessors :: IO Int (b6de8b3)
Simon Marlow
marlowsd at gmail.com
Wed Dec 7 17:54:40 CET 2011
Repository : ssh://darcs.haskell.org//srv/darcs/packages/base
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/b6de8b3968c008931277decd2d4c308a5d016292
>---------------------------------------------------------------
commit b6de8b3968c008931277decd2d4c308a5d016292
Author: Simon Marlow <marlowsd at gmail.com>
Date: Wed Dec 7 15:39:17 2011 +0000
Add getNumProcessors :: IO Int
>---------------------------------------------------------------
GHC/Conc.lhs | 1 +
GHC/Conc/Sync.lhs | 7 +++++++
2 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/GHC/Conc.lhs b/GHC/Conc.lhs
index cc6845a..a6ee11a 100644
--- a/GHC/Conc.lhs
+++ b/GHC/Conc.lhs
@@ -40,6 +40,7 @@ module GHC.Conc
, numCapabilities -- :: Int
, getNumCapabilities -- :: IO Int
, setNumCapabilities -- :: Int -> IO ()
+ , getNumProcessors -- :: IO Int
, numSparks -- :: IO Int
, childHandler -- :: Exception -> IO ()
, myThreadId -- :: IO ThreadId
diff --git a/GHC/Conc/Sync.lhs b/GHC/Conc/Sync.lhs
index fb81e27..dccab3d 100644
--- a/GHC/Conc/Sync.lhs
+++ b/GHC/Conc/Sync.lhs
@@ -50,6 +50,7 @@ module GHC.Conc.Sync
, numCapabilities -- :: Int
, getNumCapabilities -- :: IO Int
, setNumCapabilities -- :: Int -> IO ()
+ , getNumProcessors -- :: IO Int
, numSparks -- :: IO Int
, childHandler -- :: Exception -> IO ()
, myThreadId -- :: IO ThreadId
@@ -316,6 +317,12 @@ setNumCapabilities i = c_setNumCapabilities (fromIntegral i)
foreign import ccall safe "setNumCapabilities"
c_setNumCapabilities :: CUInt -> IO ()
+getNumProcessors :: IO Int
+getNumProcessors = fmap fromIntegral c_getNumberOfProcessors
+
+foreign import ccall unsafe "getNumberOfProcessors"
+ c_getNumberOfProcessors :: IO CUInt
+
-- | 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 #)
More information about the Cvs-libraries
mailing list