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

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

Simulation.Aivika.Trans.Server

Contents

Description

Tested with: GHC 8.0.1

It models the server that prodives a service.

Synopsis

Server

data Server m s a b Source #

It models a server that takes a and provides b having state s within underlying computation m.

newServer Source #

Arguments

:: MonadDES m 
=> (a -> Process m b)

provide an output by the specified input

-> Simulation m (Server m () a b) 

Create a new server that can provide output b by input a.

By default, it is assumed that the server process cannot be preempted, because the handling of possible task preemption is rather costly operation.

newStateServer Source #

Arguments

:: MonadDES m 
=> (s -> a -> Process m (s, b))

provide a new state and output by the specified old state and input

-> s

the initial state

-> Simulation m (Server m s a b) 

Create a new server that can provide output b by input a starting from state s.

By default, it is assumed that the server process cannot be preempted, because the handling of possible task preemption is rather costly operation.

newPreemptibleServer Source #

Arguments

:: MonadDES m 
=> Bool

whether the server process can be preempted

-> (a -> Process m b)

provide an output by the specified input

-> Simulation m (Server m () a b) 

Create a new preemptible server that can provide output b by input a.

newPreemptibleStateServer Source #

Arguments

:: MonadDES m 
=> Bool

whether the server process can be preempted

-> (s -> a -> Process m (s, b))

provide a new state and output by the specified old state and input

-> s

the initial state

-> Simulation m (Server m s a b) 

Create a new preemptible server that can provide output b by input a starting from state s.

Processing

serverProcessor :: MonadDES m => Server m s a b -> Processor m a b Source #

Return a processor for the specified server.

The processor updates the internal state of the server. The usual case is when the processor is applied only once in a chain of data processing. Otherwise; every time the processor is used, the state of the server changes. Sometimes it can be indeed useful if you want to aggregate the statistics for different servers simultaneously, but it would be more preferable to avoid this.

If you connect different server processors returned by this function in a chain with help of >>> or other category combinator then this chain will act as one whole, where the first server will take a new task only after the last server finishes its current task and requests for the next one from the previous processor in the chain. This is not always that thing you might need.

To model a sequence of the server processors working independently, you should use the processorSeq function which separates the processors with help of the prefetchProcessor that plays a role of a small one-place buffer in that case.

The queue processors usually have the prefetching capabilities per se, where the items are already stored in the queue. Therefore, the server processor should not be prefetched if it is connected directly to the queue processor.

Server Properties and Activities

serverInitState :: Server m s a b -> s Source #

The initial state of the server.

serverState :: MonadDES m => Server m s a b -> Event m s Source #

Return the current state of the server.

See also serverStateChanged and serverStateChanged_.

serverTotalInputWaitTime :: MonadDES m => Server m s a b -> Event m Double Source #

Return the counted total time when the server was locked while awaiting the input.

The value returned changes discretely and it is usually delayed relative to the current simulation time.

See also serverTotalInputWaitTimeChanged and serverTotalInputWaitTimeChanged_.

serverTotalProcessingTime :: MonadDES m => Server m s a b -> Event m Double Source #

Return the counted total time spent by the server while processing the tasks.

The value returned changes discretely and it is usually delayed relative to the current simulation time.

See also serverTotalProcessingTimeChanged and serverTotalProcessingTimeChanged_.

serverTotalOutputWaitTime :: MonadDES m => Server m s a b -> Event m Double Source #

Return the counted total time when the server was locked while trying to deliver the output.

The value returned changes discretely and it is usually delayed relative to the current simulation time.

See also serverTotalOutputWaitTimeChanged and serverTotalOutputWaitTimeChanged_.

serverTotalPreemptionTime :: MonadDES m => Server m s a b -> Event m Double Source #

Return the counted total time spent by the server while it was preempted waiting for the further proceeding.

The value returned changes discretely and it is usually delayed relative to the current simulation time.

See also serverTotalPreemptionTimeChanged and serverTotalPreemptionTimeChanged_.

serverInputWaitTime :: MonadDES m => Server m s a b -> Event m (SamplingStats Double) Source #

Return the statistics of the time when the server was locked while awaiting the input.

The value returned changes discretely and it is usually delayed relative to the current simulation time.

See also serverInputWaitTimeChanged and serverInputWaitTimeChanged_.

serverProcessingTime :: MonadDES m => Server m s a b -> Event m (SamplingStats Double) Source #

Return the statistics of the time spent by the server while processing the tasks.

The value returned changes discretely and it is usually delayed relative to the current simulation time.

See also serverProcessingTimeChanged and serverProcessingTimeChanged_.

serverOutputWaitTime :: MonadDES m => Server m s a b -> Event m (SamplingStats Double) Source #

Return the statistics of the time when the server was locked while trying to deliver the output.

The value returned changes discretely and it is usually delayed relative to the current simulation time.

See also serverOutputWaitTimeChanged and serverOutputWaitTimeChanged_.

serverPreemptionTime :: MonadDES m => Server m s a b -> Event m (SamplingStats Double) Source #

Return the statistics of the time spent by the server while it was preempted waiting for the further proceeding.

The value returned changes discretely and it is usually delayed relative to the current simulation time.

See also serverPreemptionTimeChanged and serverPreemptionTimeChanged_.

serverInputWaitFactor :: MonadDES m => Server m s a b -> Event m Double Source #

It returns the factor changing from 0 to 1, which estimates how often the server was awaiting for the next input task.

This factor is calculated as

  totalInputWaitTime / (totalInputWaitTime + totalProcessingTime + totalOutputWaitTime + totalPreemptionTime)

As before in this module, the value returned changes discretely and it is usually delayed relative to the current simulation time.

See also serverInputWaitFactorChanged and serverInputWaitFactorChanged_.

serverProcessingFactor :: MonadDES m => Server m s a b -> Event m Double Source #

It returns the factor changing from 0 to 1, which estimates how often the server was busy with direct processing its tasks.

This factor is calculated as

  totalProcessingTime / (totalInputWaitTime + totalProcessingTime + totalOutputWaitTime + totalPreemptionTime)

As before in this module, the value returned changes discretely and it is usually delayed relative to the current simulation time.

See also serverProcessingFactorChanged and serverProcessingFactorChanged_.

serverOutputWaitFactor :: MonadDES m => Server m s a b -> Event m Double Source #

It returns the factor changing from 0 to 1, which estimates how often the server was locked trying to deliver the output after the task is finished.

This factor is calculated as

  totalOutputWaitTime / (totalInputWaitTime + totalProcessingTime + totalOutputWaitTime + totalPreemptionTime)

As before in this module, the value returned changes discretely and it is usually delayed relative to the current simulation time.

See also serverOutputWaitFactorChanged and serverOutputWaitFactorChanged_.

serverPreemptionFactor :: MonadDES m => Server m s a b -> Event m Double Source #

It returns the factor changing from 0 to 1, which estimates how often the server was preempted waiting for the further proceeding.

This factor is calculated as

  totalPreemptionTime / (totalInputWaitTime + totalProcessingTime + totalOutputWaitTime + totalPreemptionTime)

As before in this module, the value returned changes discretely and it is usually delayed relative to the current simulation time.

See also serverPreemptionFactorChanged and serverPreemptionFactorChanged_.

Statistics Reset

resetServer :: MonadDES m => Server m s a b -> Event m () Source #

Reset the statistics.

Summary

serverSummary :: MonadDES m => Server m s a b -> Int -> Event m ShowS Source #

Return the summary for the server with desciption of its properties and activities using the specified indent.

Derived Signals for Properties

serverStateChanged :: MonadDES m => Server m s a b -> Signal m s Source #

Signal when the serverState property value has changed.

serverStateChanged_ :: MonadDES m => Server m s a b -> Signal m () Source #

Signal when the serverState property value has changed.

serverTotalInputWaitTimeChanged :: MonadDES m => Server m s a b -> Signal m Double Source #

Signal when the serverTotalInputWaitTime property value has changed.

serverTotalInputWaitTimeChanged_ :: MonadDES m => Server m s a b -> Signal m () Source #

Signal when the serverTotalInputWaitTime property value has changed.

serverTotalProcessingTimeChanged :: MonadDES m => Server m s a b -> Signal m Double Source #

Signal when the serverTotalProcessingTime property value has changed.

serverTotalProcessingTimeChanged_ :: MonadDES m => Server m s a b -> Signal m () Source #

Signal when the serverTotalProcessingTime property value has changed.

serverTotalOutputWaitTimeChanged :: MonadDES m => Server m s a b -> Signal m Double Source #

Signal when the serverTotalOutputWaitTime property value has changed.

serverTotalOutputWaitTimeChanged_ :: MonadDES m => Server m s a b -> Signal m () Source #

Signal when the serverTotalOutputWaitTime property value has changed.

serverTotalPreemptionTimeChanged :: MonadDES m => Server m s a b -> Signal m Double Source #

Signal when the serverTotalPreemptionTime property value has changed.

serverTotalPreemptionTimeChanged_ :: MonadDES m => Server m s a b -> Signal m () Source #

Signal when the serverTotalPreemptionTime property value has changed.

serverInputWaitTimeChanged :: MonadDES m => Server m s a b -> Signal m (SamplingStats Double) Source #

Signal when the serverInputWaitTime property value has changed.

serverInputWaitTimeChanged_ :: MonadDES m => Server m s a b -> Signal m () Source #

Signal when the serverInputWaitTime property value has changed.

serverProcessingTimeChanged :: MonadDES m => Server m s a b -> Signal m (SamplingStats Double) Source #

Signal when the serverProcessingTime property value has changed.

serverProcessingTimeChanged_ :: MonadDES m => Server m s a b -> Signal m () Source #

Signal when the serverProcessingTime property value has changed.

serverOutputWaitTimeChanged :: MonadDES m => Server m s a b -> Signal m (SamplingStats Double) Source #

Signal when the serverOutputWaitTime property value has changed.

serverOutputWaitTimeChanged_ :: MonadDES m => Server m s a b -> Signal m () Source #

Signal when the serverOutputWaitTime property value has changed.

serverPreemptionTimeChanged :: MonadDES m => Server m s a b -> Signal m (SamplingStats Double) Source #

Signal when the serverPreemptionTime property value has changed.

serverPreemptionTimeChanged_ :: MonadDES m => Server m s a b -> Signal m () Source #

Signal when the serverPreemptionTime property value has changed.

serverInputWaitFactorChanged :: MonadDES m => Server m s a b -> Signal m Double Source #

Signal when the serverInputWaitFactor property value has changed.

serverInputWaitFactorChanged_ :: MonadDES m => Server m s a b -> Signal m () Source #

Signal when the serverInputWaitFactor property value has changed.

serverProcessingFactorChanged :: MonadDES m => Server m s a b -> Signal m Double Source #

Signal when the serverProcessingFactor property value has changed.

serverProcessingFactorChanged_ :: MonadDES m => Server m s a b -> Signal m () Source #

Signal when the serverProcessingFactor property value has changed.

serverOutputWaitFactorChanged :: MonadDES m => Server m s a b -> Signal m Double Source #

Signal when the serverOutputWaitFactor property value has changed.

serverOutputWaitFactorChanged_ :: MonadDES m => Server m s a b -> Signal m () Source #

Signal when the serverOutputWaitFactor property value has changed.

serverPreemptionFactorChanged :: MonadDES m => Server m s a b -> Signal m Double Source #

Signal when the serverPreemptionFactor property value has changed.

serverPreemptionFactorChanged_ :: MonadDES m => Server m s a b -> Signal m () Source #

Signal when the serverPreemptionFactor property value has changed.

Basic Signals

serverInputReceived :: MonadDES m => Server m s a b -> Signal m a Source #

Raised when the server receives a new input task.

serverTaskPreemptionBeginning :: MonadDES m => Server m s a b -> Signal m a Source #

Raised when the task processing was preempted.

serverTaskPreemptionEnding :: MonadDES m => Server m s a b -> Signal m a Source #

Raised when the task processing was proceeded after it had been preempeted earlier.

serverTaskProcessed :: MonadDES m => Server m s a b -> Signal m (a, b) Source #

Raised when the server has just processed the task.

serverOutputProvided :: MonadDES m => Server m s a b -> Signal m (a, b) Source #

Raised when the server has just delivered the output.

Overall Signal

serverChanged_ :: MonadDES m => Server m s a b -> Signal m () Source #

Signal whenever any property of the server changes.