summaryrefslogtreecommitdiff
path: root/libraries
diff options
context:
space:
mode:
authorAndreas Voellmy <andreas.voellmy@gmail.com>2013-01-04 10:34:32 -0500
committerJohan Tibell <johan.tibell@gmail.com>2013-02-11 21:38:07 -0800
commit50e65e1494a66217ab03af62fbd8fa9c3ad54661 (patch)
treef4641b8cccd385e65def2453a328e9b2df2a0c1d /libraries
parent62c2749203fc03c8e62a4d86265ceb359ebe5709 (diff)
downloadhaskell-50e65e1494a66217ab03af62fbd8fa9c3ad54661.tar.gz
Undo recent change to the type of GHC.Event.Thread.getSystemEventManager and update the commentary on this function.
Diffstat (limited to 'libraries')
-rw-r--r--libraries/base/GHC/Event/Thread.hs21
1 files changed, 14 insertions, 7 deletions
diff --git a/libraries/base/GHC/Event/Thread.hs b/libraries/base/GHC/Event/Thread.hs
index b0d55a636b..2c8906e3ab 100644
--- a/libraries/base/GHC/Event/Thread.hs
+++ b/libraries/base/GHC/Event/Thread.hs
@@ -114,7 +114,7 @@ closeFdWith close fd = do
threadWait :: Event -> Fd -> IO ()
threadWait evt fd = mask_ $ do
m <- newEmptyMVar
- mgr <- getSystemEventManager
+ mgr <- getSystemEventManager_
reg <- registerFd mgr (\_ e -> putMVar m e) fd evt
evt' <- takeMVar m `onException` unregisterFd_ mgr reg
if evt' `eventIs` evtClose
@@ -125,7 +125,7 @@ threadWait evt fd = mask_ $ do
threadWaitSTM :: Event -> Fd -> IO (STM (), IO ())
threadWaitSTM evt fd = mask_ $ do
m <- newTVarIO Nothing
- mgr <- getSystemEventManager
+ mgr <- getSystemEventManager_
reg <- registerFd mgr (\_ e -> atomically (writeTVar m (Just e))) fd evt
let waitAction =
do mevt <- readTVar m
@@ -162,17 +162,24 @@ threadWaitWriteSTM = threadWaitSTM evtWrite
{-# INLINE threadWaitWriteSTM #-}
--- | Retrieve the system event manager.
+-- | Retrieve the system event manager for the capability on which the
+-- calling thread is running.
--
--- This function always returns 'Just' the system event manager when using the
--- threaded RTS and 'Nothing' otherwise.
-getSystemEventManager :: IO EventManager
+-- This function always returns 'Just' the current thread's event manager
+-- when using the threaded RTS and 'Nothing' otherwise.
+getSystemEventManager :: IO (Maybe EventManager)
getSystemEventManager = do
t <- myThreadId
(cap, _) <- threadCapability t
eventManagerArray <- readIORef eventManager
- Just (_,mgr) <- readIOArray eventManagerArray cap
+ mmgr <- readIOArray eventManagerArray cap
+ return $ fmap snd mmgr
+
+getSystemEventManager_ :: IO EventManager
+getSystemEventManager_ = do
+ Just mgr <- getSystemEventManager
return mgr
+{-# INLINE getSystemEventManager_ #-}
foreign import ccall unsafe "getOrSetSystemEventThreadEventManagerStore"
getOrSetSystemEventThreadEventManagerStore :: Ptr a -> IO (Ptr a)