Copyright | (c) Colin Woodbury 2012 - 2018 |
---|---|
License | BSD3 |
Maintainer | Colin Woodbury <colin@fosskers.ca> |
Safe Haskell | Safe |
Language | Haskell2010 |
Handle concurrent fetches from a Foldable
, throttled by the number
of CPUs that the user has available.
The canonical function is throttle
. Notice the type of function
it expects as an argument:
(TQueue a -> a -> IO b)
This TQueue
is an input queue derived from the given Foldable
. This is
exposed so that any concurrent action can dynamically grow the input.
The output is a TQueue
of the result of each IO
action.
This be can fed to further concurrent operations, or drained into a list via:
import Control.Concurrent.STM (atomically) import Control.Concurrent.STM.TQueue (TQueue, flushTQueue) flush :: TQueue a -> IO [a] flush = atomically . flushTQueue
Synopsis
- throttle :: Foldable f => (TQueue a -> a -> IO b) -> f a -> IO (TQueue b)
- throttle_ :: Foldable f => (TQueue a -> a -> IO b) -> f a -> IO ()
- throttleMaybe :: Foldable f => (TQueue a -> a -> IO (Maybe b)) -> f a -> IO (Either (TQueue b) (TQueue b))
- throttleMaybe_ :: Foldable f => (TQueue a -> a -> IO (Maybe b)) -> f a -> IO (Either () ())
Documentation
throttle_ :: Foldable f => (TQueue a -> a -> IO b) -> f a -> IO () Source #
Like throttle
, but doesn't store any output.
This is more efficient than void . throttle
.