-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Throttler between arbitrary IO producer and consumer functions
--   
--   This packages provides functionality for throttling IO using general
--   IO callbacks. The throttling depends on a provided configuration. The
--   supported throttling modes are producer throttling, consumer
--   throttling or producer &amp; consumer throttling.
@package throttle-io-stream
@version 0.2.0.1


-- | Throttle
module Control.Concurrent.Throttle

-- | Type of a measure function for items of the specified type. The
--   measure function is used by the user to specify a notion of size used
--   for throughput computations.
type Measure a = a -> Double

-- | Configuration for throttling.
data ThrottleConf a

-- | Produce a new <a>ThrottleConf</a>.
newThrottleConf :: ThrottleConf a

-- | Set measure function in configuration.
throttleConfSetMeasure :: Measure a -> ThrottleConf a -> ThrottleConf a
throttleConfThrottleConsumer :: ThrottleConf a -> ThrottleConf a
throttleConfThrottleProducer :: ThrottleConf a -> ThrottleConf a

-- | Set interval in configuration.
throttleConfSetInterval :: Double -> ThrottleConf a -> ThrottleConf a

-- | Set max throughput in configuration.
throttleConfSetMaxThroughput :: Double -> ThrottleConf a -> ThrottleConf a

-- | Set buffer size in configuration.
throttleConfSetBufferSize :: Int -> ThrottleConf a -> ThrottleConf a

-- | Set exponential weight factor used for computing current item size.
throttleConfSetEmaAlpha :: Double -> ThrottleConf a -> ThrottleConf a

-- | Asynchonously read items with the given input callback and write them
--   throttled with the given output callback.
throttle :: ThrottleConf a -> IO (Maybe a) -> (Maybe a -> IO ()) -> IO (Async ())
instance GHC.Show.Show Control.Concurrent.Throttle.Stats
