Portability | POSIX |
---|---|
Stability | experimental |
Maintainer | bastianholst@gmx.de |
Safe Haskell | Safe-Inferred |
This module contains the definition of a task buffer in the STM
monad,
TaskBufferSTM
, and possible split functions besides the functions to create a
Stack
and a Queue
buffer.
- data TaskBufferSTM a = TaskBufferSTM {
- writeBufferSTM :: a -> STM ()
- unGetBufferSTM :: a -> STM ()
- readBufferSTM :: STM a
- tryReadBufferSTM :: STM (Maybe a)
- isEmptyBufferSTM :: STM Bool
- data BufferType
- type SplitFunction r = TaskBufferSTM (IO (Maybe r)) -> TaskBufferSTM (IO (Maybe r)) -> STM (IO (Maybe r))
- takeFirst :: SplitFunction r
- splitVertical :: SplitFunction r
- splitHalf :: SplitFunction r
- newChanBufferSTM :: STM (TaskBufferSTM r)
- newStackBufferSTM :: STM (TaskBufferSTM r)
Documentation
data TaskBufferSTM a Source
A buffer holding tasks.
For this type, all access functions are using the STM
monad.
Note, that this is not a type class because we want to allow the user to select between multiple buffers other than on type level.
TaskBufferSTM | |
|
data BufferType Source
type SplitFunction r = TaskBufferSTM (IO (Maybe r)) -> TaskBufferSTM (IO (Maybe r)) -> STM (IO (Maybe r))Source
Split functions are used to split the contents of the source buffer into two parts. One part is left in this buffer or put back later; the other part is written into the sink buffer. One element of this part is returned in the STM monad. This is why the source buffer should always have at least one item available. If it has not, the action will suspend.
takeFirst :: SplitFunction rSource
Just take the first item from the source buffer.
splitVertical :: SplitFunction rSource
Split the buffer vertically. Every other element of the source remains there. All other elements are put into the sink buffer.
splitHalf :: SplitFunction rSource
Split the buffer in two halves. Takes one half out of the source buffer and puts it into the sink buffer.
newChanBufferSTM :: STM (TaskBufferSTM r)Source
Create a new Queue buffer from a TChan
.
newStackBufferSTM :: STM (TaskBufferSTM r)Source
Create a new Stack buffer from a TStack
.