Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Simple implementation for limiting the number of active threads during concurrent computations using a semaphore.
Synopsis
- mapPool :: Traversable t => Int -> (a -> IO b) -> t a -> IO (t b)
- mapCapabilityPool :: Traversable t => (a -> IO b) -> t a -> IO (t b)
Documentation
mapPool :: Traversable t => Int -> (a -> IO b) -> t a -> IO (t b) Source #
Limit the number of threads which can be active at any
given time when using mapConcurrently
. The downside is
that this function will allocate all threads at once.
mapCapabilityPool :: Traversable t => (a -> IO b) -> t a -> IO (t b) Source #
Map async using getNumCapabilities
to determine
the number of active threads.
This function is a bit misleading as it doesn't actually utilize
forkOn
or exploit any control over whether the threads are
spread across physical processors. It does, however, provide a
nice starting point for most of the threads used in this program
which are heavily IO bound.