aivika-0.4.2: A multi-paradigm simulation library

Stabilityexperimental
MaintainerDavid Sorokin <david.sorokin@gmail.com>
Safe HaskellNone

Simulation.Aivika.Dynamics.Buffer

Description

Tested with: GHC 7.4.1

This module defines the limited queue similar to LIFO and FIFO but where the items are not represented. We know only of their number in the buffer and how many items were lost.

Synopsis

Documentation

data Buffer Source

Represents the limited queue similar to LIFO and FIFO but where the items are not repsented. So, there is no order of items but their number is strictly limited.

bufferQueue :: Buffer -> EventQueueSource

Return the event queue.

bufferNull :: Buffer -> Dynamics BoolSource

Test whether the queue is empty.

bufferFull :: Buffer -> Dynamics BoolSource

Test whether the queue is full.

bufferMaxCount :: Buffer -> IntSource

The maximum available number of items.

bufferCount :: Buffer -> Dynamics IntSource

Return the queue size.

bufferLostCount :: Buffer -> Dynamics IntSource

Return the number of lost items.

newBuffer :: EventQueue -> Int -> Simulation BufferSource

Create a new queue with the specified maximum available number of items.

dequeueBuffer :: Buffer -> Process ()Source

Dequeue suspending the process if the buffer is empty.

tryDequeueBuffer :: Buffer -> Dynamics BoolSource

Try to dequeue immediately.

enqueueBuffer :: Buffer -> Process ()Source

Enqueue the item suspending the process if the buffer is full.

tryEnqueueBuffer :: Buffer -> Dynamics BoolSource

Try to enqueue the item immediately.

enqueueBufferOrLost :: Buffer -> Dynamics ()Source

Try to enqueue the item. If the buffer is full then the item will be lost.