From cdf7034e47c62807930a9da7effdbffd6cc36066 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Wed, 20 Feb 2019 14:46:01 -0800 Subject: Add some (untested) lore --- lore/Control/Concurrent/Sima.hs | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 lore/Control/Concurrent/Sima.hs (limited to 'lore/Control/Concurrent/Sima.hs') 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 -- cgit v1.2.3