Copyright | Copyright (c) 2009-2017 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 8.0.1
This module defines the queue strategies.
Synopsis
- class Monad 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 ()
- class DequeueStrategy m s => DeletingQueueStrategy m s where
- strategyQueueDelete :: Eq a => StrategyQueue m s a -> a -> Event m Bool
- strategyQueueDeleteBy :: StrategyQueue m s a -> (a -> Bool) -> Event m (Maybe a)
- strategyQueueContains :: Eq a => StrategyQueue m s a -> a -> Event m Bool
- strategyQueueContainsBy :: StrategyQueue m s a -> (a -> Bool) -> Event m (Maybe a)
- data FCFS = FCFS
- data LCFS = LCFS
- data SIRO = SIRO
- data StaticPriorities = StaticPriorities
Documentation
class Monad 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.
Instances
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.
Instances
DequeueStrategy IO FCFS Source # | An implementation of the |
Defined in Simulation.Aivika.IO.QueueStrategy strategyDequeue :: StrategyQueue IO FCFS a -> Event IO a Source # | |
DequeueStrategy IO LCFS Source # | An implementation of the |
Defined in Simulation.Aivika.IO.QueueStrategy strategyDequeue :: StrategyQueue IO LCFS a -> Event IO a Source # | |
DequeueStrategy IO SIRO Source # | An implementation of the |
Defined in Simulation.Aivika.IO.QueueStrategy strategyDequeue :: StrategyQueue IO SIRO a -> Event IO a Source # | |
DequeueStrategy IO StaticPriorities Source # | An implementation of the |
Defined in Simulation.Aivika.IO.QueueStrategy strategyDequeue :: StrategyQueue IO StaticPriorities a -> Event IO a Source # |
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.
Instances
EnqueueStrategy IO FCFS Source # | An implementation of the |
Defined in Simulation.Aivika.IO.QueueStrategy strategyEnqueue :: StrategyQueue IO FCFS a -> a -> Event IO () Source # | |
EnqueueStrategy IO LCFS Source # | An implementation of the |
Defined in Simulation.Aivika.IO.QueueStrategy strategyEnqueue :: StrategyQueue IO LCFS a -> a -> Event IO () Source # | |
EnqueueStrategy IO SIRO Source # | An implementation of the |
Defined in Simulation.Aivika.IO.QueueStrategy strategyEnqueue :: StrategyQueue IO SIRO a -> a -> Event IO () Source # |
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.
Instances
PriorityQueueStrategy IO StaticPriorities Double Source # | An implementation of the |
Defined in Simulation.Aivika.IO.QueueStrategy strategyEnqueueWithPriority :: StrategyQueue IO StaticPriorities a -> Double -> a -> Event IO () Source # |
class DequeueStrategy m s => DeletingQueueStrategy m s where Source #
Defines a strategy with support of the deleting operation.
:: Eq a | |
=> StrategyQueue m s a | the queue |
-> a | the element |
-> Event m Bool | whether the element was found and removed |
Remove the element and return a flag indicating whether the element was found and removed.
strategyQueueDeleteBy Source #
:: StrategyQueue m s a | the queue |
-> (a -> Bool) | the predicate |
-> Event m (Maybe a) | the element if it was found and removed |
Remove an element satisfying the predicate and return the element if found.
strategyQueueContains Source #
:: Eq a | |
=> StrategyQueue m s a | the queue |
-> a | the element to find |
-> Event m Bool | whether the element is contained in the queue |
Detect whether the specified element is contained in the queue.
strategyQueueContainsBy Source #
:: StrategyQueue m s a | the queue |
-> (a -> Bool) | the predicate |
-> Event m (Maybe a) | the element if it was found |
Detect whether an element satifying the specified predicate is contained in the queue.
Instances
Strategy: First Come - First Served (FCFS).
Instances
Strategy: Last Come - First Served (LCFS)
Instances
Strategy: Service in Random Order (SIRO).
Instances
data StaticPriorities Source #
Strategy: Static Priorities. It uses the priority queue.