aboutsummaryrefslogtreecommitdiffstats
path: root/app/Parallel.hs
diff options
context:
space:
mode:
authorLibravatar Alexander Foremny <aforemny@posteo.de>2023-10-14 12:20:36 +0200
committerLibravatar Alexander Foremny <aforemny@posteo.de>2023-10-14 12:25:50 +0200
commit5fea8f22f379713f0af748eb04a957ff6a9d6bfa (patch)
tree9717ef19ef6b7701b0ebda1cb65d91db53c8c48f /app/Parallel.hs
parent306587efadccf3d02c4b43efc30610ddf2697663 (diff)
utilize all processors
Diffstat (limited to 'app/Parallel.hs')
-rw-r--r--app/Parallel.hs9
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)