throttle-io-stream-0.2.0.0: Throttler between arbitrary IO producer and consumer functions

Safe HaskellSafe
LanguageHaskell2010

Control.Concurrent.Throttle

Description

Throttle

Synopsis

Documentation

type Measure a = a -> Double Source #

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.

data ThrottleConf a Source #

Configuration for throttling.

throttleConfSetMeasure :: Measure a -> ThrottleConf a -> ThrottleConf a Source #

Set measure function in configuration.

throttleConfSetInterval :: Double -> ThrottleConf a -> ThrottleConf a Source #

Set interval in configuration.

throttleConfSetMaxThroughput :: Double -> ThrottleConf a -> ThrottleConf a Source #

Set max throughput in configuration.

throttleConfSetBufferSize :: Int -> ThrottleConf a -> ThrottleConf a Source #

Set buffer size in configuration.

throttleConfSetEmaAlpha :: Double -> ThrottleConf a -> ThrottleConf a Source #

Set exponential weight factor used for computing current item size.

throttle Source #

Arguments

:: ThrottleConf a

Throttling configuration

-> IO (Maybe a)

Input callback

-> (Maybe a -> IO ())

Output callback

-> IO (Async ())

Returns an async handler for this throttling process

Asynchonously read items with the given input callback and write them throttled with the given output callback.