Copyright | Copyright (c) 2009-2014, David Sorokin <david.sorokin@gmail.com> |
---|---|
License | BSD3 |
Maintainer | David Sorokin <david.sorokin@gmail.com> |
Stability | experimental |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Tested with: GHC 7.8.3
This module defines the queue strategies.
- class MonadComp m => QueueStrategy m s where
- data StrategyQueue m s :: * -> *
- newStrategyQueue :: s -> Simulation m (StrategyQueue m s a)
- strategyQueueNull :: StrategyQueue m s a -> Event m Bool
- class QueueStrategy m s => DequeueStrategy m s where
- strategyDequeue :: StrategyQueue m s a -> Event m a
- class DequeueStrategy m s => EnqueueStrategy m s where
- strategyEnqueue :: StrategyQueue m s a -> a -> Event m ()
- class DequeueStrategy m s => PriorityQueueStrategy m s p | s -> p where
- strategyEnqueueWithPriority :: StrategyQueue m s a -> p -> a -> Event m ()
- data FCFS = FCFS
- data LCFS = LCFS
- data SIRO = SIRO
- data StaticPriorities = StaticPriorities
Documentation
class MonadComp m => QueueStrategy m s where Source
Defines the basic queue strategy.
data StrategyQueue m s :: * -> * Source
The strategy queue.
:: s | the strategy |
-> Simulation m (StrategyQueue m s a) | a new queue |
Create a new queue by the specified strategy.
:: StrategyQueue m s a | the queue |
-> Event m Bool | the result of the test |
Test whether the queue is empty.
MonadComp m => QueueStrategy m SIRO | An implementation of the |
MonadComp m => QueueStrategy m StaticPriorities | An implementation of the |
MonadComp m => QueueStrategy m LCFS | An implementation of the |
MonadComp m => QueueStrategy m FCFS | An implementation of the |
class QueueStrategy m s => DequeueStrategy m s where Source
Defines a strategy with support of the dequeuing operation.
:: StrategyQueue m s a | the queue |
-> Event m a | the dequeued element |
Dequeue the front element and return it.
QueueStrategy m SIRO => DequeueStrategy m SIRO | An implementation of the |
QueueStrategy m StaticPriorities => DequeueStrategy m StaticPriorities | An implementation of the |
QueueStrategy m LCFS => DequeueStrategy m LCFS | An implementation of the |
QueueStrategy m FCFS => DequeueStrategy m FCFS | An implementation of the |
class DequeueStrategy m s => EnqueueStrategy m s where Source
It defines a strategy when we can enqueue a single element.
:: StrategyQueue m s a | the queue |
-> a | the element to be enqueued |
-> Event m () | the action of enqueuing |
Enqueue an element.
DequeueStrategy m SIRO => EnqueueStrategy m SIRO | An implementation of the |
DequeueStrategy m LCFS => EnqueueStrategy m LCFS | An implementation of the |
DequeueStrategy m FCFS => EnqueueStrategy m FCFS | An implementation of the |
class DequeueStrategy m s => PriorityQueueStrategy m s p | s -> p where Source
It defines a strategy when we can enqueue an element with the specified priority.
strategyEnqueueWithPriority Source
:: StrategyQueue m s a | the queue |
-> p | the priority |
-> a | the element to be enqueued |
-> Event m () | the action of enqueuing |
Enqueue an element with the specified priority.
DequeueStrategy m StaticPriorities => PriorityQueueStrategy m StaticPriorities Double | An implementation of the |
Strategy: First Come - First Served (FCFS).
Eq FCFS | |
Ord FCFS | |
Show FCFS | |
DequeueStrategy m FCFS => EnqueueStrategy m FCFS | An implementation of the |
QueueStrategy m FCFS => DequeueStrategy m FCFS | An implementation of the |
MonadComp m => QueueStrategy m FCFS | An implementation of the |
ResultItemable (ResultValue FCFS) | |
data StrategyQueue m FCFS = FCFSQueue (DoubleLinkedList m a) |
Strategy: Last Come - First Served (LCFS)
Eq LCFS | |
Ord LCFS | |
Show LCFS | |
DequeueStrategy m LCFS => EnqueueStrategy m LCFS | An implementation of the |
QueueStrategy m LCFS => DequeueStrategy m LCFS | An implementation of the |
MonadComp m => QueueStrategy m LCFS | An implementation of the |
ResultItemable (ResultValue LCFS) | |
data StrategyQueue m LCFS = LCFSQueue (DoubleLinkedList m a) |
Strategy: Service in Random Order (SIRO).
Eq SIRO | |
Ord SIRO | |
Show SIRO | |
DequeueStrategy m SIRO => EnqueueStrategy m SIRO | An implementation of the |
QueueStrategy m SIRO => DequeueStrategy m SIRO | An implementation of the |
MonadComp m => QueueStrategy m SIRO | An implementation of the |
ResultItemable (ResultValue SIRO) | |
data StrategyQueue m SIRO = SIROQueue (Vector m a) |
data StaticPriorities Source
Strategy: Static Priorities. It uses the priority queue.
Eq StaticPriorities | |
Ord StaticPriorities | |
Show StaticPriorities | |
QueueStrategy m StaticPriorities => DequeueStrategy m StaticPriorities | An implementation of the |
MonadComp m => QueueStrategy m StaticPriorities | An implementation of the |
DequeueStrategy m StaticPriorities => PriorityQueueStrategy m StaticPriorities Double | An implementation of the |
ResultItemable (ResultValue StaticPriorities) | |
data StrategyQueue m StaticPriorities = StaticPriorityQueue (PriorityQueue m a) |