Safe Haskell | None |
---|---|

Language | Haskell2010 |

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

## Synopsis

- bufferConnect :: MonadBaseControl IO m => Int -> MachineT m k b -> ProcessT m b c -> MachineT m k c
- rollingConnect :: MonadBaseControl IO m => Int -> MachineT m k b -> ProcessT m b c -> MachineT m k c
- 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
- data BufferRoom a

# Blocking buffers

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

# Non-blocking (rolling) buffers

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

# 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.

#### Instances

Eq a => Eq (BufferRoom a) Source # | |

Defined in Data.Machine.Concurrent.Buffer (==) :: BufferRoom a -> BufferRoom a -> Bool # (/=) :: BufferRoom a -> BufferRoom a -> Bool # | |

Ord a => Ord (BufferRoom a) Source # | |

Defined in Data.Machine.Concurrent.Buffer compare :: BufferRoom a -> BufferRoom a -> Ordering # (<) :: BufferRoom a -> BufferRoom a -> Bool # (<=) :: BufferRoom a -> BufferRoom a -> Bool # (>) :: BufferRoom a -> BufferRoom a -> Bool # (>=) :: BufferRoom a -> BufferRoom a -> Bool # max :: BufferRoom a -> BufferRoom a -> BufferRoom a # min :: BufferRoom a -> BufferRoom a -> BufferRoom a # | |

Show a => Show (BufferRoom a) Source # | |

Defined in Data.Machine.Concurrent.Buffer showsPrec :: Int -> BufferRoom a -> ShowS # show :: BufferRoom a -> String # showList :: [BufferRoom a] -> ShowS # |