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 the queue strategies.
- class QueueStrategy s q | s -> q where
- newStrategyQueue :: s -> Simulation (q i)
- strategyQueueNull :: s -> q i -> Event Bool
- class QueueStrategy s q => DequeueStrategy s q | s -> q where
- strategyDequeue :: s -> q i -> Event i
- class DequeueStrategy s q => EnqueueStrategy s q | s -> q where
- strategyEnqueue :: s -> q i -> i -> Event ()
- class DequeueStrategy s q => PriorityQueueStrategy s q p | s -> q, s -> p where
- strategyEnqueueWithPriority :: s -> q i -> p -> i -> Event ()
- data FCFS = FCFS
- data LCFS = LCFS
- data SIRO = SIRO
- data StaticPriorities = StaticPriorities
Strategy Classes
class QueueStrategy s q | s -> q where Source
Defines the basic queue strategy.
:: s | the strategy |
-> Simulation (q i) | a new queue |
Create a new queue by the specified strategy.
Test whether the queue is empty.
class QueueStrategy s q => DequeueStrategy s q | s -> q where Source
Defines a strategy with support of the dequeuing operation.
:: s | the strategy |
-> q i | the queue |
-> Event i | the dequeued element |
Dequeue the front element and return it.
class DequeueStrategy s q => EnqueueStrategy s q | s -> q where Source
It defines a strategy when we can enqueue a single element.
:: s | the strategy |
-> q i | the queue |
-> i | the element to be enqueued |
-> Event () | the action of enqueuing |
Enqueue an element.
class DequeueStrategy s q => PriorityQueueStrategy s q p | s -> q, s -> p where Source
It defines a strategy when we can enqueue an element with the specified priority.
strategyEnqueueWithPriority Source
:: s | the strategy |
-> q i | the queue |
-> p | the priority |
-> i | the element to be enqueued |
-> Event () | the action of enqueuing |
Enqueue an element with the specified priority.
Strategy Instances
Strategy: First Come - First Served (FCFS).
Strategy: Last Come - First Served (LCFS)
Strategy: Service in Random Order (SIRO).
data StaticPriorities Source
Strategy: Static Priorities. It uses the priority queue.