Copyright | Copyright (c) 2009-2013, David Sorokin <david.sorokin@gmail.com> |
---|---|
License | BSD3 |
Maintainer | David Sorokin <david.sorokin@gmail.com> |
Stability | experimental |
Safe Haskell | Safe-Inferred |
Language | Haskell98 |
Tested with: GHC 7.6.3
This module defines an infinite queue that can use the specified strategies.
- type FCFSQueue a = Queue FCFS DoubleLinkedList FCFS DoubleLinkedList a
- type LCFSQueue a = Queue LCFS DoubleLinkedList FCFS DoubleLinkedList a
- type SIROQueue a = Queue SIRO Vector FCFS DoubleLinkedList a
- type PriorityQueue a = Queue StaticPriorities PriorityQueue FCFS DoubleLinkedList a
- data Queue sm qm so qo a
- newFCFSQueue :: Simulation (FCFSQueue a)
- newLCFSQueue :: Simulation (LCFSQueue a)
- newSIROQueue :: Simulation (SIROQueue a)
- newPriorityQueue :: Simulation (PriorityQueue a)
- newQueue :: (QueueStrategy sm qm, QueueStrategy so qo) => sm -> so -> Simulation (Queue sm qm so qo a)
- queueStoringStrategy :: Queue sm qm so qo a -> sm
- queueOutputStrategy :: Queue sm qm so qo a -> so
- queueNull :: Queue sm qm so qo a -> Event Bool
- queueCount :: Queue sm qm so qo a -> Event Int
- queueStoreCount :: Queue sm qm so qo a -> Event Int
- queueOutputRequestCount :: Queue sm qm so qo a -> Event Int
- queueOutputCount :: Queue sm qm so qo a -> Event Int
- queueStoreRate :: Queue sm qm so qo a -> Event Double
- queueOutputRequestRate :: Queue sm qm so qo a -> Event Double
- queueOutputRate :: Queue sm qm so qo a -> Event Double
- queueWaitTime :: Queue sm qm so qo a -> Event (SamplingStats Double)
- queueOutputWaitTime :: Queue sm qm so qo a -> Event (SamplingStats Double)
- dequeue :: (DequeueStrategy sm qm, EnqueueStrategy so qo) => Queue sm qm so qo a -> Process a
- dequeueWithOutputPriority :: (DequeueStrategy sm qm, PriorityQueueStrategy so qo po) => Queue sm qm so qo a -> po -> Process a
- tryDequeue :: DequeueStrategy sm qm => Queue sm qm so qo a -> Event (Maybe a)
- enqueue :: (EnqueueStrategy sm qm, DequeueStrategy so qo) => Queue sm qm so qo a -> a -> Event ()
- enqueueWithStoringPriority :: (PriorityQueueStrategy sm qm pm, DequeueStrategy so qo) => Queue sm qm so qo a -> pm -> a -> Event ()
- queueSummary :: (Show sm, Show so) => Queue sm qm so qo a -> Int -> Event ShowS
- queueNullChanged :: Queue sm qm so qo a -> Signal Bool
- queueNullChanged_ :: Queue sm qm so qo a -> Signal ()
- queueCountChanged :: Queue sm qm so qo a -> Signal Int
- queueCountChanged_ :: Queue sm qm so qo a -> Signal ()
- queueStoreCountChanged :: Queue sm qm so qo a -> Signal Int
- queueStoreCountChanged_ :: Queue sm qm so qo a -> Signal ()
- queueOutputRequestCountChanged :: Queue sm qm so qo a -> Signal Int
- queueOutputRequestCountChanged_ :: Queue sm qm so qo a -> Signal ()
- queueOutputCountChanged :: Queue sm qm so qo a -> Signal Int
- queueOutputCountChanged_ :: Queue sm qm so qo a -> Signal ()
- queueWaitTimeChanged :: Queue sm qm so qo a -> Signal (SamplingStats Double)
- queueWaitTimeChanged_ :: Queue sm qm so qo a -> Signal ()
- queueOutputWaitTimeChanged :: Queue sm qm so qo a -> Signal (SamplingStats Double)
- queueOutputWaitTimeChanged_ :: Queue sm qm so qo a -> Signal ()
- enqueueStored :: Queue sm qm so qo a -> Signal a
- dequeueRequested :: Queue sm qm so qo a -> Signal ()
- dequeueExtracted :: Queue sm qm so qo a -> Signal a
- queueChanged_ :: Queue sm qm so qo a -> Signal ()
Queue Types
type FCFSQueue a = Queue FCFS DoubleLinkedList FCFS DoubleLinkedList a Source
A type synonym for the ordinary FIFO queue also known as the FCFS (First Come - First Serviced) queue.
type LCFSQueue a = Queue LCFS DoubleLinkedList FCFS DoubleLinkedList a Source
A type synonym for the ordinary LIFO queue also known as the LCFS (Last Come - First Serviced) queue.
type SIROQueue a = Queue SIRO Vector FCFS DoubleLinkedList a Source
A type synonym for the SIRO (Serviced in Random Order) queue.
type PriorityQueue a = Queue StaticPriorities PriorityQueue FCFS DoubleLinkedList a Source
A type synonym for the queue with static priorities applied when storing the elements in the queue.
data Queue sm qm so qo a Source
Represents the infinite queue using the specified strategies for
internal storing (in memory) sm
and output so
, where a
denotes
the type of items stored in the queue. Types qm
and qo
are
determined automatically and you should not care about them - they
are dependent types.
Creating Queue
newFCFSQueue :: Simulation (FCFSQueue a) Source
Create a new infinite FCFS queue.
newLCFSQueue :: Simulation (LCFSQueue a) Source
Create a new infinite LCFS queue.
newSIROQueue :: Simulation (SIROQueue a) Source
Create a new infinite SIRO queue.
newPriorityQueue :: Simulation (PriorityQueue a) Source
Create a new infinite priority queue.
:: (QueueStrategy sm qm, QueueStrategy so qo) | |
=> sm | the strategy applied when storing items in the queue |
-> so | the strategy applied to the output (dequeuing) process |
-> Simulation (Queue sm qm so qo a) |
Create a new infinite queue with the specified strategies.
Queue Properties and Activities
queueStoringStrategy :: Queue sm qm so qo a -> sm Source
The strategy applied when storing (in memory) items in the queue.
queueOutputStrategy :: Queue sm qm so qo a -> so Source
The strategy applied to the output (dequeuing) process.
queueNull :: Queue sm qm so qo a -> Event Bool Source
Test whether the queue is empty.
See also queueNullChanged
and queueNullChanged_
.
queueCount :: Queue sm qm so qo a -> Event Int Source
Return the queue size.
See also queueCountChanged
and queueCountChanged_
.
queueStoreCount :: Queue sm qm so qo a -> Event Int Source
Return the total number of input items that were stored.
See also queueStoreCountChanged
and queueStoreCountChanged_
.
queueOutputRequestCount :: Queue sm qm so qo a -> Event Int Source
Return the total number of requests for dequeueing the items, not taking into account the attempts to dequeue immediately without suspension.
See also queueOutputRequestCountChanged
and queueOutputRequestCountChanged_
.
queueOutputCount :: Queue sm qm so qo a -> Event Int Source
Return the total number of output items that were dequeued.
See also queueOutputCountChanged
and queueOutputCountChanged_
.
queueStoreRate :: Queue sm qm so qo a -> Event Double Source
Return the rate of the items that were stored: how many items per time.
queueOutputRequestRate :: Queue sm qm so qo a -> Event Double Source
Return the rate of the requests for dequeueing the items: how many requests per time. It does not include the attempts to dequeue immediately without suspension.
queueOutputRate :: Queue sm qm so qo a -> Event Double Source
Return the rate of the output items that were dequeued: how many items per time.
queueWaitTime :: Queue sm qm so qo a -> Event (SamplingStats Double) Source
Return the wait time from the time at which the item was stored in the queue to the time at which it was dequeued.
See also queueWaitTimeChanged
and queueWaitTimeChanged_
.
queueOutputWaitTime :: Queue sm qm so qo a -> Event (SamplingStats Double) Source
Return the output wait time from the time at which the item was requested for dequeueing to the time at which it was actually dequeued.
See also queueOutputWaitTimeChanged
and queueOutputWaitTimeChanged_
.
Dequeuing and Enqueuing
:: (DequeueStrategy sm qm, EnqueueStrategy so qo) | |
=> Queue sm qm so qo a | the queue |
-> Process a | the dequeued value |
Dequeue suspending the process if the queue is empty.
dequeueWithOutputPriority Source
:: (DequeueStrategy sm qm, PriorityQueueStrategy so qo po) | |
=> Queue sm qm so qo a | the queue |
-> po | the priority for output |
-> Process a | the dequeued value |
Dequeue with the output priority suspending the process if the queue is empty.
:: DequeueStrategy sm qm | |
=> Queue sm qm so qo a | the queue |
-> Event (Maybe a) | the dequeued value of |
Try to dequeue immediately.
:: (EnqueueStrategy sm qm, DequeueStrategy so qo) | |
=> Queue sm qm so qo a | the queue |
-> a | the item to enqueue |
-> Event () |
Enqueue the item.
enqueueWithStoringPriority Source
:: (PriorityQueueStrategy sm qm pm, DequeueStrategy so qo) | |
=> Queue sm qm so qo a | the queue |
-> pm | the priority for storing |
-> a | the item to enqueue |
-> Event () |
Enqueue with the storing priority the item.
Summary
queueSummary :: (Show sm, Show so) => Queue sm qm so qo a -> Int -> Event ShowS Source
Return the summary for the queue with desciption of its properties and activities using the specified indent.
Derived Signals for Properties
queueNullChanged :: Queue sm qm so qo a -> Signal Bool Source
Signal when the queueNull
property value has changed.
queueNullChanged_ :: Queue sm qm so qo a -> Signal () Source
Signal when the queueNull
property value has changed.
queueCountChanged :: Queue sm qm so qo a -> Signal Int Source
Signal when the queueCount
property value has changed.
queueCountChanged_ :: Queue sm qm so qo a -> Signal () Source
Signal when the queueCount
property value has changed.
queueStoreCountChanged :: Queue sm qm so qo a -> Signal Int Source
Signal when the queueStoreCount
property value has changed.
queueStoreCountChanged_ :: Queue sm qm so qo a -> Signal () Source
Signal when the queueStoreCount
property value has changed.
queueOutputRequestCountChanged :: Queue sm qm so qo a -> Signal Int Source
Signal when the queueOutputRequestCount
property value has changed.
queueOutputRequestCountChanged_ :: Queue sm qm so qo a -> Signal () Source
Signal when the queueOutputRequestCount
property value has changed.
queueOutputCountChanged :: Queue sm qm so qo a -> Signal Int Source
Signal when the queueOutputCount
property value has changed.
queueOutputCountChanged_ :: Queue sm qm so qo a -> Signal () Source
Signal when the queueOutputCount
property value has changed.
queueWaitTimeChanged :: Queue sm qm so qo a -> Signal (SamplingStats Double) Source
Signal when the queueWaitTime
property value has changed.
queueWaitTimeChanged_ :: Queue sm qm so qo a -> Signal () Source
Signal when the queueWaitTime
property value has changed.
queueOutputWaitTimeChanged :: Queue sm qm so qo a -> Signal (SamplingStats Double) Source
Signal when the queueOutputWaitTime
property value has changed.
queueOutputWaitTimeChanged_ :: Queue sm qm so qo a -> Signal () Source
Signal when the queueOutputWaitTime
property value has changed.
Basic Signals
enqueueStored :: Queue sm qm so qo a -> Signal a Source
Return a signal that notifies when the enqueued item is stored in the internal memory of the queue.
dequeueRequested :: Queue sm qm so qo a -> Signal () Source
Return a signal that notifies when the dequeuing operation was requested.
dequeueExtracted :: Queue sm qm so qo a -> Signal a Source
Return a signal that notifies when the item was extracted from the internal storage of the queue and prepared for immediate receiving by the dequeuing process.
Overall Signal
queueChanged_ :: Queue sm qm so qo a -> Signal () Source
Signal whenever any property of the queue changes.
The property must have the corresponded signal. There are also characteristics similar to the properties but that have no signals. As a rule, such characteristics already depend on the simulation time and therefore they may change at any time point.