blob: e59016436482eb6da7123c9455070fd2c56ad521 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
module Parallel (parMapM, parMapM_, parSequence) where
import Control.Concurrent.ParallelIO.Local (parallel, parallel_, withPool)
import GHC.Conc (getNumProcessors)
parMapM :: (a -> IO b) -> [a] -> IO [b]
parMapM f xs = do
n <- getNumProcessors
withPool n $ \pool -> parallel pool (map f xs)
parMapM_ :: (a -> IO ()) -> [a] -> IO ()
parMapM_ f xs = do
n <- getNumProcessors
withPool n $ \pool -> parallel_ pool (map f xs)
parSequence :: [IO a] -> IO [a]
parSequence xs = do
n <- getNumProcessors
withPool n $ \pool -> parallel pool xs
|