aivika-transformers-4.3.3: Transformers for the Aivika simulation library

CopyrightCopyright (c) 2009-2015, David Sorokin <david.sorokin@gmail.com>
LicenseBSD3
MaintainerDavid Sorokin <david.sorokin@gmail.com>
Stabilityexperimental
Safe HaskellSafe
LanguageHaskell2010

Simulation.Aivika.Trans.QueueStrategy

Description

Tested with: GHC 7.10.1

This module defines the queue strategies.

Synopsis

Documentation

class Monad m => QueueStrategy m s where Source

Defines the basic queue strategy.

Associated Types

data StrategyQueue m s :: * -> * Source

The strategy queue.

Methods

newStrategyQueue Source

Arguments

:: s

the strategy

-> Simulation m (StrategyQueue m s a)

a new queue

Create a new queue by the specified strategy.

strategyQueueNull Source

Arguments

:: StrategyQueue m s a

the queue

-> Event m Bool

the result of the test

Test whether the queue is empty.

class QueueStrategy m s => DequeueStrategy m s where Source

Defines a strategy with support of the dequeuing operation.

Methods

strategyDequeue Source

Arguments

:: StrategyQueue m s a

the queue

-> Event m a

the dequeued element

Dequeue the front element and return it.

class DequeueStrategy m s => EnqueueStrategy m s where Source

It defines a strategy when we can enqueue a single element.

Methods

strategyEnqueue Source

Arguments

:: StrategyQueue m s a

the queue

-> a

the element to be enqueued

-> Event m ()

the action of enqueuing

Enqueue an element.

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.

Methods

strategyEnqueueWithPriority Source

Arguments

:: 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.

class DequeueStrategy m s => DeletingQueueStrategy m s where Source

Defines a strategy with support of the deleting operation.

Methods

strategyQueueDelete Source

Arguments

:: 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

Arguments

:: 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

Arguments

:: 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

Arguments

:: 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.

data FCFS Source

Strategy: First Come - First Served (FCFS).

Constructors

FCFS 

data LCFS Source

Strategy: Last Come - First Served (LCFS)

Constructors

LCFS 

data SIRO Source

Strategy: Service in Random Order (SIRO).

Constructors

SIRO