summaryrefslogtreecommitdiff
path: root/lore/Control/Concurrent/Sima.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lore/Control/Concurrent/Sima.hs')
-rw-r--r--lore/Control/Concurrent/Sima.hs12
1 files changed, 12 insertions, 0 deletions
diff --git a/lore/Control/Concurrent/Sima.hs b/lore/Control/Concurrent/Sima.hs
new file mode 100644
index 0000000..3588a2a
--- /dev/null
+++ b/lore/Control/Concurrent/Sima.hs
@@ -0,0 +1,12 @@
+module Control.Concurrent.Simaphore
+ ( mapPool
+ )
+where
+
+import Control.Concurrent.MSem
+
+-- | Simaphore-based throttled 'mapConcurrently'.
+mapPool :: Traversable t => Int -> (a -> IO b) -> t a -> IO (t b)
+mapPool lim f xs = do
+ sima <- new lim
+ mapConcurrently (with sima . f) xs