diff options
author | Ben Sima <ben@bsima.me> | 2019-02-20 14:46:01 -0800 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2019-02-20 14:46:12 -0800 |
commit | cdf7034e47c62807930a9da7effdbffd6cc36066 (patch) | |
tree | ddb397f9dff12048e98ae8d6dbf6d7d1158f3c0c /lore/Control/Concurrent/Sima.hs | |
parent | b116a9ddc16744ad6ff7021cadf24bd60849433b (diff) |
Add some (untested) lore
Diffstat (limited to 'lore/Control/Concurrent/Sima.hs')
-rw-r--r-- | lore/Control/Concurrent/Sima.hs | 12 |
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 |