aivika-0.5.4: A multi-paradigm simulation library

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

Simulation.Aivika.Dynamics.LIFO

Description

Tested with: GHC 7.6.3

This module defines the LIFO queue.

Synopsis

Documentation

data LIFO a Source

Represents the LIFO queue with rule: last input - first output.

lifoQueue :: LIFO a -> EventQueueSource

Return the event queue.

lifoNull :: LIFO a -> Dynamics BoolSource

Test whether the LIFO queue is empty.

lifoFull :: LIFO a -> Dynamics BoolSource

Test whether the LIFO queue is full.

lifoMaxCount :: LIFO a -> IntSource

The maximum available number of items.

lifoCount :: LIFO a -> Dynamics IntSource

Return the queue size.

lifoLostCount :: LIFO a -> Dynamics IntSource

Return the number of lost items.

lifoEnqueue :: LIFO a -> Signal aSource

Return a signal that notifies when any item is enqueued.

lifoDequeue :: LIFO a -> Signal aSource

Return a signal that notifies when any item is dequeued.

lifoEnqueueLost :: LIFO 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 enqueueLIFOOrLost.

newLIFO :: EventQueue -> Int -> Simulation (LIFO a)Source

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

dequeueLIFO :: LIFO a -> Process aSource

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

tryDequeueLIFO :: LIFO a -> Dynamics (Maybe a)Source

Try to dequeue from the LIFO queue immediately.

enqueueLIFO :: LIFO a -> a -> Process ()Source

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

tryEnqueueLIFO :: LIFO a -> a -> Dynamics BoolSource

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

enqueueLIFOOrLost :: LIFO a -> a -> Dynamics ()Source

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