Contains a combinator for concurrently joining a producer and a consumer, such that the producer may continue to produce (up to the queue size) as the consumer is concurrently consuming.
- buffer :: (MonadBaseControl IO m, MonadIO m) => Int -> Producer m a -> Consumer a m b -> m b
- ($$&) :: (MonadIO m, MonadBaseControl IO m) => Producer m a -> Consumer a m b -> m b
- gatherFrom :: (MonadIO m, MonadBaseControl IO m) => Int -> (TBQueue o -> m ()) -> Producer m o
- drainTo :: (MonadIO m, MonadBaseControl IO m) => Int -> (TBQueue (Maybe i) -> m r) -> Consumer i m r
Concurrently join the producer and consumer, using a bounded queue of the given size. The producer will block when the queue is full, if it is producing faster than the consumers is taking from it. Likewise, if the consumer races ahead, it will block until more input is available.
Exceptions are properly managed and propagated between the two sides, so the net effect should be equivalent to not using buffer at all, save for the concurrent interleaving of effects.
|:: (MonadIO m, MonadBaseControl IO m)|
Size of the queue to create
|-> (TBQueue o -> m ())|
Action that generates output values
|-> Producer m o|
Gather output values asynchronously from an action in the base monad and
then yield them downstream. This provides a means of working around the
ConduitM cannot be an instance of
in order to, for example, yield values from within a Haskell callback
function called from a C library.