lawless-concurrent-machines-0.3.1: Concurrent networked stream transducers

Safe HaskellNone
LanguageHaskell2010

Data.Machine.Concurrent.Buffer

Contents

Description

Place buffers between two machines. This is most useful with irregular production rates.

Synopsis

Blocking buffers

bufferConnect :: MonadBaseControl IO m => Int -> MachineT m k b -> ProcessT m b c -> MachineT m k c Source #

Mediate a MachineT and a ProcessT with a bounded capacity buffer. The source machine runs concurrently with the sink process, and is only blocked when the buffer is full.

Non-blocking (rolling) buffers

rollingConnect :: MonadBaseControl IO m => Int -> MachineT m k b -> ProcessT m b c -> MachineT m k c Source #

Mediate a MachineT and a ProcessT with a rolling buffer. The source machine runs concurrently with the sink process and is never blocked. If the sink process can not keep up with upstream, yielded values will be dropped.

Internal helpers

mediatedConnect :: forall m t b k c. MonadBaseControl IO m => t -> (t -> b -> BufferRoom t) -> (t -> Maybe (b, t)) -> MachineT m k b -> ProcessT m b c -> MachineT m k c Source #

Mediate a MachineT and a ProcessT with a buffer.

mediatedConnect z snoc view source sink pipes source into sink through a buffer initialized to z and updated with snoc. Upstream is blocked if snoc indicates that the buffer is full after adding a new element. Downstream blocks if view indicates that the buffer is empty. Otherwise, view is expected to return the next element to process and an updated buffer.

data BufferRoom a Source #

Indication if the payload value is "full" or not.

Constructors

NoVacancy a 
Vacancy a