summaryrefslogtreecommitdiff
path: root/libraries/base/GHC/Event/Thread.hs
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/base/GHC/Event/Thread.hs')
-rw-r--r--libraries/base/GHC/Event/Thread.hs11
1 files changed, 6 insertions, 5 deletions
diff --git a/libraries/base/GHC/Event/Thread.hs b/libraries/base/GHC/Event/Thread.hs
index 6fe76895ad..482e41f172 100644
--- a/libraries/base/GHC/Event/Thread.hs
+++ b/libraries/base/GHC/Event/Thread.hs
@@ -16,14 +16,14 @@ module GHC.Event.Thread
) where
import Control.Exception (finally, SomeException, toException)
-import Control.Monad (forM, forM_, sequence_, zipWithM)
+import Data.Foldable (forM_, mapM_, sequence_)
import Data.IORef (IORef, newIORef, readIORef, writeIORef)
import Data.Tuple (snd)
import Foreign.C.Error (eBADF, errnoToIOError)
import Foreign.C.Types (CInt(..), CUInt(..))
import Foreign.Ptr (Ptr)
import GHC.Base
-import GHC.List (zipWith3)
+import GHC.List (zipWith, zipWith3)
import GHC.Conc.Sync (TVar, ThreadId, ThreadStatus(..), atomically, forkIO,
labelThread, modifyMVar_, withMVar, newTVar, sharedCAF,
getNumCapabilities, threadCapability, myThreadId, forkOn,
@@ -99,15 +99,16 @@ closeFdWith :: (Fd -> IO ()) -- ^ Action that performs the close.
closeFdWith close fd = do
eventManagerArray <- readIORef eventManager
let (low, high) = boundsIOArray eventManagerArray
- mgrs <- forM [low..high] $ \i -> do
+ mgrs <- flip mapM [low..high] $ \i -> do
Just (_,!mgr) <- readIOArray eventManagerArray i
return mgr
mask_ $ do
- tables <- forM mgrs $ \mgr -> takeMVar $ M.callbackTableVar mgr fd
+ tables <- flip mapM mgrs $ \mgr -> takeMVar $ M.callbackTableVar mgr fd
cbApps <- zipWithM (\mgr table -> M.closeFd_ mgr table fd) mgrs tables
close fd `finally` sequence_ (zipWith3 finish mgrs tables cbApps)
where
finish mgr table cbApp = putMVar (M.callbackTableVar mgr fd) table >> cbApp
+ zipWithM f xs ys = sequence (zipWith f xs ys)
threadWait :: Event -> Fd -> IO ()
threadWait evt fd = mask_ $ do
@@ -244,7 +245,7 @@ startIOManagerThreads =
withMVar ioManagerLock $ \_ -> do
eventManagerArray <- readIORef eventManager
let (_, high) = boundsIOArray eventManagerArray
- forM_ [0..high] (startIOManagerThread eventManagerArray)
+ mapM_ (startIOManagerThread eventManagerArray) [0..high]
writeIORef numEnabledEventManagers (high+1)
show_int :: Int -> String