diff options
Diffstat (limited to 'app/Parallel.hs')
-rw-r--r-- | app/Parallel.hs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/app/Parallel.hs b/app/Parallel.hs new file mode 100644 index 0000000..0b57545 --- /dev/null +++ b/app/Parallel.hs @@ -0,0 +1,9 @@ +module Parallel (parMapM) where + +import Control.Concurrent.ParallelIO.Local (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) |