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
It models the server that prodives a service.
- data Server s a b
- newServer :: (a -> Process b) -> Simulation (Server () a b)
- newStateServer :: (s -> a -> Process (s, b)) -> s -> Simulation (Server s a b)
- serverProcessor :: Server s a b -> Processor a b
- serverInitState :: Server s a b -> s
- serverState :: Server s a b -> Event s
- serverTotalInputWaitTime :: Server s a b -> Event Double
- serverTotalProcessingTime :: Server s a b -> Event Double
- serverTotalOutputWaitTime :: Server s a b -> Event Double
- serverInputWaitTime :: Server s a b -> Event (SamplingStats Double)
- serverProcessingTime :: Server s a b -> Event (SamplingStats Double)
- serverOutputWaitTime :: Server s a b -> Event (SamplingStats Double)
- serverInputWaitFactor :: Server s a b -> Event Double
- serverProcessingFactor :: Server s a b -> Event Double
- serverOutputWaitFactor :: Server s a b -> Event Double
- serverSummary :: Server s a b -> Int -> Event ShowS
- serverStateChanged :: Server s a b -> Signal s
- serverStateChanged_ :: Server s a b -> Signal ()
- serverTotalInputWaitTimeChanged :: Server s a b -> Signal Double
- serverTotalInputWaitTimeChanged_ :: Server s a b -> Signal ()
- serverTotalProcessingTimeChanged :: Server s a b -> Signal Double
- serverTotalProcessingTimeChanged_ :: Server s a b -> Signal ()
- serverTotalOutputWaitTimeChanged :: Server s a b -> Signal Double
- serverTotalOutputWaitTimeChanged_ :: Server s a b -> Signal ()
- serverInputWaitTimeChanged :: Server s a b -> Signal (SamplingStats Double)
- serverInputWaitTimeChanged_ :: Server s a b -> Signal ()
- serverProcessingTimeChanged :: Server s a b -> Signal (SamplingStats Double)
- serverProcessingTimeChanged_ :: Server s a b -> Signal ()
- serverOutputWaitTimeChanged :: Server s a b -> Signal (SamplingStats Double)
- serverOutputWaitTimeChanged_ :: Server s a b -> Signal ()
- serverInputWaitFactorChanged :: Server s a b -> Signal Double
- serverInputWaitFactorChanged_ :: Server s a b -> Signal ()
- serverProcessingFactorChanged :: Server s a b -> Signal Double
- serverProcessingFactorChanged_ :: Server s a b -> Signal ()
- serverOutputWaitFactorChanged :: Server s a b -> Signal Double
- serverOutputWaitFactorChanged_ :: Server s a b -> Signal ()
- serverInputReceived :: Server s a b -> Signal a
- serverTaskProcessed :: Server s a b -> Signal (a, b)
- serverOutputProvided :: Server s a b -> Signal (a, b)
- serverChanged_ :: Server s a b -> Signal ()
Server
It models a server that takes a
and provides b
having state s
.
(Show s, ResultItemable (ResultValue s)) => ResultProvider (Server s a b) |
:: (a -> Process b) | provide an output by the specified input |
-> Simulation (Server () a b) |
Create a new server that can provide output b
by input a
.
:: (s -> a -> Process (s, b)) | provide a new state and output by the specified old state and input |
-> s | the initial state |
-> Simulation (Server s a b) |
Create a new server that can provide output b
by input a
starting from state s
.
Processing
serverProcessor :: Server s a b -> Processor 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 with the queue processor.
Server Properties and Activities
serverInitState :: Server s a b -> s Source
The initial state of the server.
serverState :: Server s a b -> Event s Source
Return the current state of the server.
See also serverStateChanged
and serverStateChanged_
.
serverTotalInputWaitTime :: Server s a b -> Event 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 :: Server s a b -> Event 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 :: Server s a b -> Event 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_
.
serverInputWaitTime :: Server s a b -> Event (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 :: Server s a b -> Event (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 :: Server s a b -> Event (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_
.
serverInputWaitFactor :: Server s a b -> Event 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)
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 :: Server s a b -> Event 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)
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 :: Server s a b -> Event 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)
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_
.
Summary
serverSummary :: Server s a b -> Int -> Event ShowS Source
Return the summary for the server with desciption of its properties and activities using the specified indent.
Derived Signals for Properties
serverStateChanged :: Server s a b -> Signal s Source
Signal when the serverState
property value has changed.
serverStateChanged_ :: Server s a b -> Signal () Source
Signal when the serverState
property value has changed.
serverTotalInputWaitTimeChanged :: Server s a b -> Signal Double Source
Signal when the serverTotalInputWaitTime
property value has changed.
serverTotalInputWaitTimeChanged_ :: Server s a b -> Signal () Source
Signal when the serverTotalInputWaitTime
property value has changed.
serverTotalProcessingTimeChanged :: Server s a b -> Signal Double Source
Signal when the serverTotalProcessingTime
property value has changed.
serverTotalProcessingTimeChanged_ :: Server s a b -> Signal () Source
Signal when the serverTotalProcessingTime
property value has changed.
serverTotalOutputWaitTimeChanged :: Server s a b -> Signal Double Source
Signal when the serverTotalOutputWaitTime
property value has changed.
serverTotalOutputWaitTimeChanged_ :: Server s a b -> Signal () Source
Signal when the serverTotalOutputWaitTime
property value has changed.
serverInputWaitTimeChanged :: Server s a b -> Signal (SamplingStats Double) Source
Signal when the serverInputWaitTime
property value has changed.
serverInputWaitTimeChanged_ :: Server s a b -> Signal () Source
Signal when the serverInputWaitTime
property value has changed.
serverProcessingTimeChanged :: Server s a b -> Signal (SamplingStats Double) Source
Signal when the serverProcessingTime
property value has changed.
serverProcessingTimeChanged_ :: Server s a b -> Signal () Source
Signal when the serverProcessingTime
property value has changed.
serverOutputWaitTimeChanged :: Server s a b -> Signal (SamplingStats Double) Source
Signal when the serverOutputWaitTime
property value has changed.
serverOutputWaitTimeChanged_ :: Server s a b -> Signal () Source
Signal when the serverOutputWaitTime
property value has changed.
serverInputWaitFactorChanged :: Server s a b -> Signal Double Source
Signal when the serverInputWaitFactor
property value has changed.
serverInputWaitFactorChanged_ :: Server s a b -> Signal () Source
Signal when the serverInputWaitFactor
property value has changed.
serverProcessingFactorChanged :: Server s a b -> Signal Double Source
Signal when the serverProcessingFactor
property value has changed.
serverProcessingFactorChanged_ :: Server s a b -> Signal () Source
Signal when the serverProcessingFactor
property value has changed.
serverOutputWaitFactorChanged :: Server s a b -> Signal Double Source
Signal when the serverOutputWaitFactor
property value has changed.
serverOutputWaitFactorChanged_ :: Server s a b -> Signal () Source
Signal when the serverOutputWaitFactor
property value has changed.
Basic Signals
serverInputReceived :: Server s a b -> Signal a Source
Raised when the server receives a new input task.
serverTaskProcessed :: Server s a b -> Signal (a, b) Source
Raised when the server has just processed the task.
serverOutputProvided :: Server s a b -> Signal (a, b) Source
Raised when the server has just delivered the output.
Overall Signal
serverChanged_ :: Server s a b -> Signal () Source
Signal whenever any property of the server changes.