aivika-0.5.1: A multi-paradigm simulation library

Stabilityexperimental
MaintainerDavid Sorokin <david.sorokin@gmail.com>
Safe HaskellSafe-Inferred

Simulation.Aivika.Dynamics.FIFO

Description

Tested with: GHC 7.4.1

This module defines the FIFO queue.

Synopsis

Documentation

data FIFO a Source

Represents the FIFO queue with rule: first input - first output.

fifoQueue :: FIFO a -> EventQueueSource

Return the event queue.

fifoNull :: FIFO a -> Dynamics BoolSource

Test whether the FIFO queue is empty.

fifoFull :: FIFO a -> Dynamics BoolSource

Test whether the FIFO queue is full.

fifoMaxCount :: FIFO a -> IntSource

The maximum available number of items.

fifoCount :: FIFO a -> Dynamics IntSource

Return the queue size.

fifoLostCount :: FIFO a -> Dynamics IntSource

Return the number of lost items.

fifoEnqueue :: FIFO a -> Signal aSource

Return a signal that notifies when any item is enqueued.

fifoDequeue :: FIFO a -> Signal aSource

Return a signal that notifies when any item is dequeued.

fifoEnqueueLost :: FIFO a -> Signal aSource

Return a signal which notifies that the item was lost when attempting to add it to the full queue with help of enqueueFIFOOrLost.

newFIFO :: EventQueue -> Int -> Simulation (FIFO a)Source

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

dequeueFIFO :: FIFO a -> Process aSource

Dequeue from the FIFO queue suspending the process if the queue is empty.

tryDequeueFIFO :: FIFO a -> Dynamics (Maybe a)Source

Try to dequeue from the FIFO queue immediately.

enqueueFIFO :: FIFO a -> a -> Process ()Source

Enqueue the item in the FIFO queue suspending the process if the queue is full.

tryEnqueueFIFO :: FIFO a -> a -> Dynamics BoolSource

Try to enqueue the item in the FIFO queue. Return False in the monad if the queue is full.

enqueueFIFOOrLost :: FIFO a -> a -> Dynamics ()Source

Try to enqueue the item in the FIFO queue. If the queue is full then the item will be lost.