| Stability | experimental |
|---|---|
| Maintainer | David Sorokin <david.sorokin@gmail.com> |
| Safe Haskell | Safe-Inferred |
Simulation.Aivika.Queue
Description
Tested with: GHC 7.6.3
This module defines a queue that can use the specified strategies. So, having only
the FCFS, LCFS, SIRO and StaticPriorities strategies, you can build
4 x 3 x 4 = 48 different types of the queue, each of them will have its own
behavior (below StaticPriorities can be used for input and output only).
- data Queue si qi sm qm so qo a
- queueNull :: Queue si qi sm qm so qo a -> Event Bool
- queueFull :: Queue si qi sm qm so qo a -> Event Bool
- queueMaxCount :: Queue si qi sm qm so qo a -> Int
- queueCount :: Queue si qi sm qm so qo a -> Event Int
- queueLostCount :: Queue si qi sm qm so qo a -> Event Int
- enqueued :: Queue si qi sm qm so qo a -> Signal a
- dequeued :: Queue si qi sm qm so qo a -> Signal a
- enqueuedButLost :: Queue si qi sm qm so qo a -> Signal a
- newQueue :: (QueueStrategy si qi, QueueStrategy sm qm, QueueStrategy so qo) => si -> sm -> so -> Int -> Simulation (Queue si qi sm qm so qo a)
- dequeue :: (DequeueStrategy si qi, DequeueStrategy sm qm, EnqueueStrategy so qo) => Queue si qi sm qm so qo a -> Process a
- dequeueWithPriority :: (DequeueStrategy si qi, DequeueStrategy sm qm, PriorityQueueStrategy so qo) => Queue si qi sm qm so qo a -> Double -> Process a
- dequeueWithDynamicPriority :: (DequeueStrategy si qi, DequeueStrategy sm qm, DynamicPriorityQueueStrategy so qo) => Queue si qi sm qm so qo a -> Event Double -> Process a
- tryDequeue :: (DequeueStrategy si qi, DequeueStrategy sm qm) => Queue si qi sm qm so qo a -> Event (Maybe a)
- enqueue :: (EnqueueStrategy si qi, EnqueueStrategy sm qm, DequeueStrategy so qo) => Queue si qi sm qm so qo a -> a -> Process ()
- enqueueWithPriority :: (PriorityQueueStrategy si qi, EnqueueStrategy sm qm, DequeueStrategy so qo) => Queue si qi sm qm so qo a -> Double -> a -> Process ()
- enqueueWithDynamicPriority :: (DynamicPriorityQueueStrategy si qi, EnqueueStrategy sm qm, DequeueStrategy so qo) => Queue si qi sm qm so qo a -> Event Double -> a -> Process ()
- tryEnqueue :: (EnqueueStrategy sm qm, DequeueStrategy so qo) => Queue si qi sm qm so qo a -> a -> Event Bool
- enqueueOrLost :: (EnqueueStrategy sm qm, DequeueStrategy so qo) => Queue si qi sm qm so qo a -> a -> Event Bool
- enqueueOrLost_ :: (EnqueueStrategy sm qm, DequeueStrategy so qo) => Queue si qi sm qm so qo a -> a -> Event ()
Documentation
data Queue si qi sm qm so qo a Source
Represents the queue using the specified strategies for input si,
internal storing (in memory) sm and output so, where a denotes
the type of items stored in the queue. Types qi, qm and qo are
determined automatically and you should not care about them - they
are dependent types.
queueMaxCount :: Queue si qi sm qm so qo a -> IntSource
The maximum available number of items.
queueCount :: Queue si qi sm qm so qo a -> Event IntSource
Return the queue size.
queueLostCount :: Queue si qi sm qm so qo a -> Event IntSource
Return the number of lost items.
enqueued :: Queue si qi sm qm so qo a -> Signal aSource
Return a signal that notifies when any item is enqueued.
dequeued :: Queue si qi sm qm so qo a -> Signal aSource
Return a signal that notifies when any item is dequeued.
enqueuedButLost :: Queue si qi sm qm so qo 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
enqueueOrLost or enqueueOrLost_.
Arguments
| :: (QueueStrategy si qi, QueueStrategy sm qm, QueueStrategy so qo) | |
| => si | the strategy applied to the input (enqueuing) process |
| -> sm | the strategy applied when storing items in the queue |
| -> so | the strategy applied to the output (dequeuing) process |
| -> Int | the maximum available number of items |
| -> Simulation (Queue si qi sm qm so qo a) |
Create a new queue with the specified strategies and maximum available number of items.
Arguments
| :: (DequeueStrategy si qi, DequeueStrategy sm qm, EnqueueStrategy so qo) | |
| => Queue si qi sm qm so qo a | the queue |
| -> Process a | the dequeued value |
Dequeue suspending the process if the queue is empty.
Arguments
| :: (DequeueStrategy si qi, DequeueStrategy sm qm, PriorityQueueStrategy so qo) | |
| => Queue si qi sm qm so qo a | the queue |
| -> Double | the priority |
| -> Process a | the dequeued value |
Dequeue with the priority suspending the process if the queue is empty.
dequeueWithDynamicPrioritySource
Arguments
| :: (DequeueStrategy si qi, DequeueStrategy sm qm, DynamicPriorityQueueStrategy so qo) | |
| => Queue si qi sm qm so qo a | the queue |
| -> Event Double | the dynamic priority |
| -> Process a | the dequeued value |
Dequeue with the dynamic priority suspending the process if the queue is empty.
Arguments
| :: (DequeueStrategy si qi, DequeueStrategy sm qm) | |
| => Queue si qi sm qm so qo a | the queue |
| -> Event (Maybe a) | the dequeued value of |
Try to dequeue from the queue immediately.
Arguments
| :: (EnqueueStrategy si qi, EnqueueStrategy sm qm, DequeueStrategy so qo) | |
| => Queue si qi sm qm so qo a | the queue |
| -> a | the item to enqueue |
| -> Process () |
Enqueue the item suspending the process if the queue is full.
Arguments
| :: (PriorityQueueStrategy si qi, EnqueueStrategy sm qm, DequeueStrategy so qo) | |
| => Queue si qi sm qm so qo a | the queue |
| -> Double | the priority |
| -> a | the item to enqueue |
| -> Process () |
Enqueue with the priority the item suspending the process if the queue is full.
enqueueWithDynamicPrioritySource
Arguments
| :: (DynamicPriorityQueueStrategy si qi, EnqueueStrategy sm qm, DequeueStrategy so qo) | |
| => Queue si qi sm qm so qo a | the queue |
| -> Event Double | the dynamic priority |
| -> a | the item to enqueue |
| -> Process () |
Enqueue with the dynamic priority the item suspending the process if the queue is full.
Arguments
| :: (EnqueueStrategy sm qm, DequeueStrategy so qo) | |
| => Queue si qi sm qm so qo a | the queue |
| -> a | the item which we try to enqueue |
| -> Event Bool |
Try to enqueue the item. Return False in the monad if the queue is full.
Arguments
| :: (EnqueueStrategy sm qm, DequeueStrategy so qo) | |
| => Queue si qi sm qm so qo a | the queue |
| -> a | the item which we try to enqueue |
| -> Event Bool |
Try to enqueue the item. If the queue is full then the item will be lost
and False will be returned.
Arguments
| :: (EnqueueStrategy sm qm, DequeueStrategy so qo) | |
| => Queue si qi sm qm so qo a | the queue |
| -> a | the item which we try to enqueue |
| -> Event () |
Try to enqueue the item. If the queue is full then the item will be lost.