summaryrefslogtreecommitdiff
path: root/lore/Control/Concurrent/Sima.hs
blob: 3588a2a7249850d94d3c092127a0d026a676b7cf (plain)
1
2
3
4
5
6
7
8
9
10
11
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