module Simulation.Aivika.Server
(
Server,
newServer,
newStateServer,
newPreemptibleServer,
newPreemptibleStateServer,
serverProcessor,
serverInitState,
serverState,
serverTotalInputWaitTime,
serverTotalProcessingTime,
serverTotalOutputWaitTime,
serverTotalPreemptionTime,
serverInputWaitTime,
serverProcessingTime,
serverOutputWaitTime,
serverPreemptionTime,
serverInputWaitFactor,
serverProcessingFactor,
serverOutputWaitFactor,
serverPreemptionFactor,
resetServer,
serverSummary,
serverStateChanged,
serverStateChanged_,
serverTotalInputWaitTimeChanged,
serverTotalInputWaitTimeChanged_,
serverTotalProcessingTimeChanged,
serverTotalProcessingTimeChanged_,
serverTotalOutputWaitTimeChanged,
serverTotalOutputWaitTimeChanged_,
serverTotalPreemptionTimeChanged,
serverTotalPreemptionTimeChanged_,
serverInputWaitTimeChanged,
serverInputWaitTimeChanged_,
serverProcessingTimeChanged,
serverProcessingTimeChanged_,
serverOutputWaitTimeChanged,
serverOutputWaitTimeChanged_,
serverPreemptionTimeChanged,
serverPreemptionTimeChanged_,
serverInputWaitFactorChanged,
serverInputWaitFactorChanged_,
serverProcessingFactorChanged,
serverProcessingFactorChanged_,
serverOutputWaitFactorChanged,
serverOutputWaitFactorChanged_,
serverPreemptionFactorChanged,
serverPreemptionFactorChanged_,
serverInputReceived,
serverTaskPreemptionBeginning,
serverTaskPreemptionEnding,
serverTaskProcessed,
serverOutputProvided,
serverChanged_) where
import Data.IORef
import Data.Monoid
import Control.Monad
import Control.Monad.Trans
import Control.Arrow
import Simulation.Aivika.Simulation
import Simulation.Aivika.Dynamics
import Simulation.Aivika.Internal.Event
import Simulation.Aivika.Signal
import Simulation.Aivika.Cont
import Simulation.Aivika.Process
import Simulation.Aivika.Processor
import Simulation.Aivika.Stream
import Simulation.Aivika.Statistics
data Server s a b =
Server { Server s a b -> s
serverInitState :: s,
Server s a b -> IORef s
serverStateRef :: IORef s,
Server s a b -> s -> a -> Process (s, b)
serverProcess :: s -> a -> Process (s, b),
Server s a b -> Bool
serverProcessPreemptible :: Bool,
Server s a b -> IORef Double
serverTotalInputWaitTimeRef :: IORef Double,
Server s a b -> IORef Double
serverTotalProcessingTimeRef :: IORef Double,
Server s a b -> IORef Double
serverTotalOutputWaitTimeRef :: IORef Double,
Server s a b -> IORef Double
serverTotalPreemptionTimeRef :: IORef Double,
Server s a b -> IORef (SamplingStats Double)
serverInputWaitTimeRef :: IORef (SamplingStats Double),
Server s a b -> IORef (SamplingStats Double)
serverProcessingTimeRef :: IORef (SamplingStats Double),
Server s a b -> IORef (SamplingStats Double)
serverOutputWaitTimeRef :: IORef (SamplingStats Double),
Server s a b -> IORef (SamplingStats Double)
serverPreemptionTimeRef :: IORef (SamplingStats Double),
Server s a b -> SignalSource a
serverInputReceivedSource :: SignalSource a,
Server s a b -> SignalSource a
serverTaskPreemptionBeginningSource :: SignalSource a,
Server s a b -> SignalSource a
serverTaskPreemptionEndingSource :: SignalSource a,
Server s a b -> SignalSource (a, b)
serverTaskProcessedSource :: SignalSource (a, b),
Server s a b -> SignalSource (a, b)
serverOutputProvidedSource :: SignalSource (a, b)
}
newServer :: (a -> Process b)
-> Simulation (Server () a b)
newServer :: (a -> Process b) -> Simulation (Server () a b)
newServer = Bool -> (a -> Process b) -> Simulation (Server () a b)
forall a b. Bool -> (a -> Process b) -> Simulation (Server () a b)
newPreemptibleServer Bool
False
newStateServer :: (s -> a -> Process (s, b))
-> s
-> Simulation (Server s a b)
newStateServer :: (s -> a -> Process (s, b)) -> s -> Simulation (Server s a b)
newStateServer = Bool
-> (s -> a -> Process (s, b)) -> s -> Simulation (Server s a b)
forall s a b.
Bool
-> (s -> a -> Process (s, b)) -> s -> Simulation (Server s a b)
newPreemptibleStateServer Bool
False
newPreemptibleServer :: Bool
-> (a -> Process b)
-> Simulation (Server () a b)
newPreemptibleServer :: Bool -> (a -> Process b) -> Simulation (Server () a b)
newPreemptibleServer Bool
preemptible a -> Process b
provide =
((() -> a -> Process ((), b)) -> () -> Simulation (Server () a b))
-> () -> (() -> a -> Process ((), b)) -> Simulation (Server () a b)
forall a b c. (a -> b -> c) -> b -> a -> c
flip (Bool
-> (() -> a -> Process ((), b)) -> () -> Simulation (Server () a b)
forall s a b.
Bool
-> (s -> a -> Process (s, b)) -> s -> Simulation (Server s a b)
newPreemptibleStateServer Bool
preemptible) () ((() -> a -> Process ((), b)) -> Simulation (Server () a b))
-> (() -> a -> Process ((), b)) -> Simulation (Server () a b)
forall a b. (a -> b) -> a -> b
$ \()
s a
a ->
do b
b <- a -> Process b
provide a
a
((), b) -> Process ((), b)
forall (m :: * -> *) a. Monad m => a -> m a
return (()
s, b
b)
newPreemptibleStateServer :: Bool
-> (s -> a -> Process (s, b))
-> s
-> Simulation (Server s a b)
newPreemptibleStateServer :: Bool
-> (s -> a -> Process (s, b)) -> s -> Simulation (Server s a b)
newPreemptibleStateServer Bool
preemptible s -> a -> Process (s, b)
provide s
state =
do IORef s
r0 <- IO (IORef s) -> Simulation (IORef s)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (IORef s) -> Simulation (IORef s))
-> IO (IORef s) -> Simulation (IORef s)
forall a b. (a -> b) -> a -> b
$ s -> IO (IORef s)
forall a. a -> IO (IORef a)
newIORef s
state
IORef Double
r1 <- IO (IORef Double) -> Simulation (IORef Double)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (IORef Double) -> Simulation (IORef Double))
-> IO (IORef Double) -> Simulation (IORef Double)
forall a b. (a -> b) -> a -> b
$ Double -> IO (IORef Double)
forall a. a -> IO (IORef a)
newIORef Double
0
IORef Double
r2 <- IO (IORef Double) -> Simulation (IORef Double)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (IORef Double) -> Simulation (IORef Double))
-> IO (IORef Double) -> Simulation (IORef Double)
forall a b. (a -> b) -> a -> b
$ Double -> IO (IORef Double)
forall a. a -> IO (IORef a)
newIORef Double
0
IORef Double
r3 <- IO (IORef Double) -> Simulation (IORef Double)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (IORef Double) -> Simulation (IORef Double))
-> IO (IORef Double) -> Simulation (IORef Double)
forall a b. (a -> b) -> a -> b
$ Double -> IO (IORef Double)
forall a. a -> IO (IORef a)
newIORef Double
0
IORef Double
r4 <- IO (IORef Double) -> Simulation (IORef Double)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (IORef Double) -> Simulation (IORef Double))
-> IO (IORef Double) -> Simulation (IORef Double)
forall a b. (a -> b) -> a -> b
$ Double -> IO (IORef Double)
forall a. a -> IO (IORef a)
newIORef Double
0
IORef (SamplingStats Double)
r5 <- IO (IORef (SamplingStats Double))
-> Simulation (IORef (SamplingStats Double))
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (IORef (SamplingStats Double))
-> Simulation (IORef (SamplingStats Double)))
-> IO (IORef (SamplingStats Double))
-> Simulation (IORef (SamplingStats Double))
forall a b. (a -> b) -> a -> b
$ SamplingStats Double -> IO (IORef (SamplingStats Double))
forall a. a -> IO (IORef a)
newIORef SamplingStats Double
forall a. SamplingData a => SamplingStats a
emptySamplingStats
IORef (SamplingStats Double)
r6 <- IO (IORef (SamplingStats Double))
-> Simulation (IORef (SamplingStats Double))
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (IORef (SamplingStats Double))
-> Simulation (IORef (SamplingStats Double)))
-> IO (IORef (SamplingStats Double))
-> Simulation (IORef (SamplingStats Double))
forall a b. (a -> b) -> a -> b
$ SamplingStats Double -> IO (IORef (SamplingStats Double))
forall a. a -> IO (IORef a)
newIORef SamplingStats Double
forall a. SamplingData a => SamplingStats a
emptySamplingStats
IORef (SamplingStats Double)
r7 <- IO (IORef (SamplingStats Double))
-> Simulation (IORef (SamplingStats Double))
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (IORef (SamplingStats Double))
-> Simulation (IORef (SamplingStats Double)))
-> IO (IORef (SamplingStats Double))
-> Simulation (IORef (SamplingStats Double))
forall a b. (a -> b) -> a -> b
$ SamplingStats Double -> IO (IORef (SamplingStats Double))
forall a. a -> IO (IORef a)
newIORef SamplingStats Double
forall a. SamplingData a => SamplingStats a
emptySamplingStats
IORef (SamplingStats Double)
r8 <- IO (IORef (SamplingStats Double))
-> Simulation (IORef (SamplingStats Double))
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (IORef (SamplingStats Double))
-> Simulation (IORef (SamplingStats Double)))
-> IO (IORef (SamplingStats Double))
-> Simulation (IORef (SamplingStats Double))
forall a b. (a -> b) -> a -> b
$ SamplingStats Double -> IO (IORef (SamplingStats Double))
forall a. a -> IO (IORef a)
newIORef SamplingStats Double
forall a. SamplingData a => SamplingStats a
emptySamplingStats
SignalSource a
s1 <- Simulation (SignalSource a)
forall a. Simulation (SignalSource a)
newSignalSource
SignalSource a
s2 <- Simulation (SignalSource a)
forall a. Simulation (SignalSource a)
newSignalSource
SignalSource a
s3 <- Simulation (SignalSource a)
forall a. Simulation (SignalSource a)
newSignalSource
SignalSource (a, b)
s4 <- Simulation (SignalSource (a, b))
forall a. Simulation (SignalSource a)
newSignalSource
SignalSource (a, b)
s5 <- Simulation (SignalSource (a, b))
forall a. Simulation (SignalSource a)
newSignalSource
let server :: Server s a b
server = Server :: forall s a b.
s
-> IORef s
-> (s -> a -> Process (s, b))
-> Bool
-> IORef Double
-> IORef Double
-> IORef Double
-> IORef Double
-> IORef (SamplingStats Double)
-> IORef (SamplingStats Double)
-> IORef (SamplingStats Double)
-> IORef (SamplingStats Double)
-> SignalSource a
-> SignalSource a
-> SignalSource a
-> SignalSource (a, b)
-> SignalSource (a, b)
-> Server s a b
Server { serverInitState :: s
serverInitState = s
state,
serverStateRef :: IORef s
serverStateRef = IORef s
r0,
serverProcess :: s -> a -> Process (s, b)
serverProcess = s -> a -> Process (s, b)
provide,
serverProcessPreemptible :: Bool
serverProcessPreemptible = Bool
preemptible,
serverTotalInputWaitTimeRef :: IORef Double
serverTotalInputWaitTimeRef = IORef Double
r1,
serverTotalProcessingTimeRef :: IORef Double
serverTotalProcessingTimeRef = IORef Double
r2,
serverTotalOutputWaitTimeRef :: IORef Double
serverTotalOutputWaitTimeRef = IORef Double
r3,
serverTotalPreemptionTimeRef :: IORef Double
serverTotalPreemptionTimeRef = IORef Double
r4,
serverInputWaitTimeRef :: IORef (SamplingStats Double)
serverInputWaitTimeRef = IORef (SamplingStats Double)
r5,
serverProcessingTimeRef :: IORef (SamplingStats Double)
serverProcessingTimeRef = IORef (SamplingStats Double)
r6,
serverOutputWaitTimeRef :: IORef (SamplingStats Double)
serverOutputWaitTimeRef = IORef (SamplingStats Double)
r7,
serverPreemptionTimeRef :: IORef (SamplingStats Double)
serverPreemptionTimeRef = IORef (SamplingStats Double)
r8,
serverInputReceivedSource :: SignalSource a
serverInputReceivedSource = SignalSource a
s1,
serverTaskPreemptionBeginningSource :: SignalSource a
serverTaskPreemptionBeginningSource = SignalSource a
s2,
serverTaskPreemptionEndingSource :: SignalSource a
serverTaskPreemptionEndingSource = SignalSource a
s3,
serverTaskProcessedSource :: SignalSource (a, b)
serverTaskProcessedSource = SignalSource (a, b)
s4,
serverOutputProvidedSource :: SignalSource (a, b)
serverOutputProvidedSource = SignalSource (a, b)
s5 }
Server s a b -> Simulation (Server s a b)
forall (m :: * -> *) a. Monad m => a -> m a
return Server s a b
server
serverProcessor :: Server s a b -> Processor a b
serverProcessor :: Server s a b -> Processor a b
serverProcessor Server s a b
server =
(Stream a -> Stream b) -> Processor a b
forall a b. (Stream a -> Stream b) -> Processor a b
Processor ((Stream a -> Stream b) -> Processor a b)
-> (Stream a -> Stream b) -> Processor a b
forall a b. (a -> b) -> a -> b
$ \Stream a
xs -> s -> Maybe (Double, a, b) -> Stream a -> Stream b
loop (Server s a b -> s
forall s a b. Server s a b -> s
serverInitState Server s a b
server) Maybe (Double, a, b)
forall a. Maybe a
Nothing Stream a
xs
where
loop :: s -> Maybe (Double, a, b) -> Stream a -> Stream b
loop s
s Maybe (Double, a, b)
r Stream a
xs =
Process (b, Stream b) -> Stream b
forall a. Process (a, Stream a) -> Stream a
Cons (Process (b, Stream b) -> Stream b)
-> Process (b, Stream b) -> Stream b
forall a b. (a -> b) -> a -> b
$
do Double
t0 <- Dynamics Double -> Process Double
forall (m :: * -> *) a. DynamicsLift m => Dynamics a -> m a
liftDynamics Dynamics Double
time
Event () -> Process ()
forall (m :: * -> *) a. EventLift m => Event a -> m a
liftEvent (Event () -> Process ()) -> Event () -> Process ()
forall a b. (a -> b) -> a -> b
$
case Maybe (Double, a, b)
r of
Maybe (Double, a, b)
Nothing -> () -> Event ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
Just (Double
t', a
a', b
b') ->
do IO () -> Event ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> Event ()) -> IO () -> Event ()
forall a b. (a -> b) -> a -> b
$
do IORef Double -> (Double -> Double) -> IO ()
forall a. IORef a -> (a -> a) -> IO ()
modifyIORef' (Server s a b -> IORef Double
forall s a b. Server s a b -> IORef Double
serverTotalOutputWaitTimeRef Server s a b
server) (Double -> Double -> Double
forall a. Num a => a -> a -> a
+ (Double
t0 Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
t'))
IORef (SamplingStats Double)
-> (SamplingStats Double -> SamplingStats Double) -> IO ()
forall a. IORef a -> (a -> a) -> IO ()
modifyIORef' (Server s a b -> IORef (SamplingStats Double)
forall s a b. Server s a b -> IORef (SamplingStats Double)
serverOutputWaitTimeRef Server s a b
server) ((SamplingStats Double -> SamplingStats Double) -> IO ())
-> (SamplingStats Double -> SamplingStats Double) -> IO ()
forall a b. (a -> b) -> a -> b
$
Double -> SamplingStats Double -> SamplingStats Double
forall a. SamplingData a => a -> SamplingStats a -> SamplingStats a
addSamplingStats (Double
t0 Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
t')
SignalSource (a, b) -> (a, b) -> Event ()
forall a. SignalSource a -> a -> Event ()
triggerSignal (Server s a b -> SignalSource (a, b)
forall s a b. Server s a b -> SignalSource (a, b)
serverOutputProvidedSource Server s a b
server) (a
a', b
b')
(a
a, Stream a
xs') <- Stream a -> Process (a, Stream a)
forall a. Stream a -> Process (a, Stream a)
runStream Stream a
xs
Double
t1 <- Dynamics Double -> Process Double
forall (m :: * -> *) a. DynamicsLift m => Dynamics a -> m a
liftDynamics Dynamics Double
time
Event () -> Process ()
forall (m :: * -> *) a. EventLift m => Event a -> m a
liftEvent (Event () -> Process ()) -> Event () -> Process ()
forall a b. (a -> b) -> a -> b
$
do IO () -> Event ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> Event ()) -> IO () -> Event ()
forall a b. (a -> b) -> a -> b
$
do IORef Double -> (Double -> Double) -> IO ()
forall a. IORef a -> (a -> a) -> IO ()
modifyIORef' (Server s a b -> IORef Double
forall s a b. Server s a b -> IORef Double
serverTotalInputWaitTimeRef Server s a b
server) (Double -> Double -> Double
forall a. Num a => a -> a -> a
+ (Double
t1 Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
t0))
IORef (SamplingStats Double)
-> (SamplingStats Double -> SamplingStats Double) -> IO ()
forall a. IORef a -> (a -> a) -> IO ()
modifyIORef' (Server s a b -> IORef (SamplingStats Double)
forall s a b. Server s a b -> IORef (SamplingStats Double)
serverInputWaitTimeRef Server s a b
server) ((SamplingStats Double -> SamplingStats Double) -> IO ())
-> (SamplingStats Double -> SamplingStats Double) -> IO ()
forall a b. (a -> b) -> a -> b
$
Double -> SamplingStats Double -> SamplingStats Double
forall a. SamplingData a => a -> SamplingStats a -> SamplingStats a
addSamplingStats (Double
t1 Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
t0)
SignalSource a -> a -> Event ()
forall a. SignalSource a -> a -> Event ()
triggerSignal (Server s a b -> SignalSource a
forall s a b. Server s a b -> SignalSource a
serverInputReceivedSource Server s a b
server) a
a
(s
s', b
b, Double
dt) <-
if Server s a b -> Bool
forall s a b. Server s a b -> Bool
serverProcessPreemptible Server s a b
server
then Server s a b -> s -> a -> Process (s, b, Double)
forall s a b. Server s a b -> s -> a -> Process (s, b, Double)
serverProcessPreempting Server s a b
server s
s a
a
else do (s
s', b
b) <- Server s a b -> s -> a -> Process (s, b)
forall s a b. Server s a b -> s -> a -> Process (s, b)
serverProcess Server s a b
server s
s a
a
(s, b, Double) -> Process (s, b, Double)
forall (m :: * -> *) a. Monad m => a -> m a
return (s
s', b
b, Double
0)
Double
t2 <- Dynamics Double -> Process Double
forall (m :: * -> *) a. DynamicsLift m => Dynamics a -> m a
liftDynamics Dynamics Double
time
Event () -> Process ()
forall (m :: * -> *) a. EventLift m => Event a -> m a
liftEvent (Event () -> Process ()) -> Event () -> Process ()
forall a b. (a -> b) -> a -> b
$
do IO () -> Event ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> Event ()) -> IO () -> Event ()
forall a b. (a -> b) -> a -> b
$
do IORef s -> s -> IO ()
forall a. IORef a -> a -> IO ()
writeIORef (Server s a b -> IORef s
forall s a b. Server s a b -> IORef s
serverStateRef Server s a b
server) (s -> IO ()) -> s -> IO ()
forall a b. (a -> b) -> a -> b
$! s
s'
IORef Double -> (Double -> Double) -> IO ()
forall a. IORef a -> (a -> a) -> IO ()
modifyIORef' (Server s a b -> IORef Double
forall s a b. Server s a b -> IORef Double
serverTotalProcessingTimeRef Server s a b
server) (Double -> Double -> Double
forall a. Num a => a -> a -> a
+ (Double
t2 Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
t1 Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
dt))
IORef (SamplingStats Double)
-> (SamplingStats Double -> SamplingStats Double) -> IO ()
forall a. IORef a -> (a -> a) -> IO ()
modifyIORef' (Server s a b -> IORef (SamplingStats Double)
forall s a b. Server s a b -> IORef (SamplingStats Double)
serverProcessingTimeRef Server s a b
server) ((SamplingStats Double -> SamplingStats Double) -> IO ())
-> (SamplingStats Double -> SamplingStats Double) -> IO ()
forall a b. (a -> b) -> a -> b
$
Double -> SamplingStats Double -> SamplingStats Double
forall a. SamplingData a => a -> SamplingStats a -> SamplingStats a
addSamplingStats (Double
t2 Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
t1 Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
dt)
SignalSource (a, b) -> (a, b) -> Event ()
forall a. SignalSource a -> a -> Event ()
triggerSignal (Server s a b -> SignalSource (a, b)
forall s a b. Server s a b -> SignalSource (a, b)
serverTaskProcessedSource Server s a b
server) (a
a, b
b)
(b, Stream b) -> Process (b, Stream b)
forall (m :: * -> *) a. Monad m => a -> m a
return (b
b, s -> Maybe (Double, a, b) -> Stream a -> Stream b
loop s
s' ((Double, a, b) -> Maybe (Double, a, b)
forall a. a -> Maybe a
Just (Double
t2, a
a, b
b)) Stream a
xs')
serverProcessPreempting :: Server s a b -> s -> a -> Process (s, b, Double)
serverProcessPreempting :: Server s a b -> s -> a -> Process (s, b, Double)
serverProcessPreempting Server s a b
server s
s a
a =
do ProcessId
pid <- Process ProcessId
processId
Double
t1 <- Dynamics Double -> Process Double
forall (m :: * -> *) a. DynamicsLift m => Dynamics a -> m a
liftDynamics Dynamics Double
time
IORef Double
rs <- IO (IORef Double) -> Process (IORef Double)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (IORef Double) -> Process (IORef Double))
-> IO (IORef Double) -> Process (IORef Double)
forall a b. (a -> b) -> a -> b
$ Double -> IO (IORef Double)
forall a. a -> IO (IORef a)
newIORef Double
0
IORef Double
r1 <- IO (IORef Double) -> Process (IORef Double)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (IORef Double) -> Process (IORef Double))
-> IO (IORef Double) -> Process (IORef Double)
forall a b. (a -> b) -> a -> b
$ Double -> IO (IORef Double)
forall a. a -> IO (IORef a)
newIORef Double
t1
DisposableEvent
h1 <- Event DisposableEvent -> Process DisposableEvent
forall (m :: * -> *) a. EventLift m => Event a -> m a
liftEvent (Event DisposableEvent -> Process DisposableEvent)
-> Event DisposableEvent -> Process DisposableEvent
forall a b. (a -> b) -> a -> b
$
Signal () -> (() -> Event ()) -> Event DisposableEvent
forall a. Signal a -> (a -> Event ()) -> Event DisposableEvent
handleSignal (ProcessId -> Signal ()
processPreemptionBeginning ProcessId
pid) ((() -> Event ()) -> Event DisposableEvent)
-> (() -> Event ()) -> Event DisposableEvent
forall a b. (a -> b) -> a -> b
$ \() ->
do Double
t1 <- Dynamics Double -> Event Double
forall (m :: * -> *) a. DynamicsLift m => Dynamics a -> m a
liftDynamics Dynamics Double
time
IO () -> Event ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> Event ()) -> IO () -> Event ()
forall a b. (a -> b) -> a -> b
$ IORef Double -> Double -> IO ()
forall a. IORef a -> a -> IO ()
writeIORef IORef Double
r1 Double
t1
SignalSource a -> a -> Event ()
forall a. SignalSource a -> a -> Event ()
triggerSignal (Server s a b -> SignalSource a
forall s a b. Server s a b -> SignalSource a
serverTaskPreemptionBeginningSource Server s a b
server) a
a
DisposableEvent
h2 <- Event DisposableEvent -> Process DisposableEvent
forall (m :: * -> *) a. EventLift m => Event a -> m a
liftEvent (Event DisposableEvent -> Process DisposableEvent)
-> Event DisposableEvent -> Process DisposableEvent
forall a b. (a -> b) -> a -> b
$
Signal () -> (() -> Event ()) -> Event DisposableEvent
forall a. Signal a -> (a -> Event ()) -> Event DisposableEvent
handleSignal (ProcessId -> Signal ()
processPreemptionEnding ProcessId
pid) ((() -> Event ()) -> Event DisposableEvent)
-> (() -> Event ()) -> Event DisposableEvent
forall a b. (a -> b) -> a -> b
$ \() ->
do Double
t1 <- IO Double -> Event Double
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Double -> Event Double) -> IO Double -> Event Double
forall a b. (a -> b) -> a -> b
$ IORef Double -> IO Double
forall a. IORef a -> IO a
readIORef IORef Double
r1
Double
t2 <- Dynamics Double -> Event Double
forall (m :: * -> *) a. DynamicsLift m => Dynamics a -> m a
liftDynamics Dynamics Double
time
let dt :: Double
dt = Double
t2 Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
t1
IO () -> Event ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> Event ()) -> IO () -> Event ()
forall a b. (a -> b) -> a -> b
$
do IORef Double -> (Double -> Double) -> IO ()
forall a. IORef a -> (a -> a) -> IO ()
modifyIORef' IORef Double
rs (Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
dt)
IORef Double -> (Double -> Double) -> IO ()
forall a. IORef a -> (a -> a) -> IO ()
modifyIORef' (Server s a b -> IORef Double
forall s a b. Server s a b -> IORef Double
serverTotalPreemptionTimeRef Server s a b
server) (Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
dt)
IORef (SamplingStats Double)
-> (SamplingStats Double -> SamplingStats Double) -> IO ()
forall a. IORef a -> (a -> a) -> IO ()
modifyIORef' (Server s a b -> IORef (SamplingStats Double)
forall s a b. Server s a b -> IORef (SamplingStats Double)
serverPreemptionTimeRef Server s a b
server) ((SamplingStats Double -> SamplingStats Double) -> IO ())
-> (SamplingStats Double -> SamplingStats Double) -> IO ()
forall a b. (a -> b) -> a -> b
$
Double -> SamplingStats Double -> SamplingStats Double
forall a. SamplingData a => a -> SamplingStats a -> SamplingStats a
addSamplingStats Double
dt
SignalSource a -> a -> Event ()
forall a. SignalSource a -> a -> Event ()
triggerSignal (Server s a b -> SignalSource a
forall s a b. Server s a b -> SignalSource a
serverTaskPreemptionEndingSource Server s a b
server) a
a
let m1 :: Process (s, b, Double)
m1 =
do (s
s', b
b) <- Server s a b -> s -> a -> Process (s, b)
forall s a b. Server s a b -> s -> a -> Process (s, b)
serverProcess Server s a b
server s
s a
a
Double
dt <- IO Double -> Process Double
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Double -> Process Double) -> IO Double -> Process Double
forall a b. (a -> b) -> a -> b
$ IORef Double -> IO Double
forall a. IORef a -> IO a
readIORef IORef Double
rs
(s, b, Double) -> Process (s, b, Double)
forall (m :: * -> *) a. Monad m => a -> m a
return (s
s', b
b, Double
dt)
m2 :: Process ()
m2 =
Event () -> Process ()
forall (m :: * -> *) a. EventLift m => Event a -> m a
liftEvent (Event () -> Process ()) -> Event () -> Process ()
forall a b. (a -> b) -> a -> b
$
do DisposableEvent -> Event ()
disposeEvent DisposableEvent
h1
DisposableEvent -> Event ()
disposeEvent DisposableEvent
h2
Process (s, b, Double) -> Process () -> Process (s, b, Double)
forall a b. Process a -> Process b -> Process a
finallyProcess Process (s, b, Double)
m1 Process ()
m2
serverState :: Server s a b -> Event s
serverState :: Server s a b -> Event s
serverState Server s a b
server =
(Point -> IO s) -> Event s
forall a. (Point -> IO a) -> Event a
Event ((Point -> IO s) -> Event s) -> (Point -> IO s) -> Event s
forall a b. (a -> b) -> a -> b
$ \Point
p -> IORef s -> IO s
forall a. IORef a -> IO a
readIORef (Server s a b -> IORef s
forall s a b. Server s a b -> IORef s
serverStateRef Server s a b
server)
serverStateChanged :: Server s a b -> Signal s
serverStateChanged :: Server s a b -> Signal s
serverStateChanged Server s a b
server =
(() -> Event s) -> Signal () -> Signal s
forall a b. (a -> Event b) -> Signal a -> Signal b
mapSignalM (Event s -> () -> Event s
forall a b. a -> b -> a
const (Event s -> () -> Event s) -> Event s -> () -> Event s
forall a b. (a -> b) -> a -> b
$ Server s a b -> Event s
forall s a b. Server s a b -> Event s
serverState Server s a b
server) (Server s a b -> Signal ()
forall s a b. Server s a b -> Signal ()
serverStateChanged_ Server s a b
server)
serverStateChanged_ :: Server s a b -> Signal ()
serverStateChanged_ :: Server s a b -> Signal ()
serverStateChanged_ Server s a b
server =
((a, b) -> ()) -> Signal (a, b) -> Signal ()
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (() -> (a, b) -> ()
forall a b. a -> b -> a
const ()) (Server s a b -> Signal (a, b)
forall s a b. Server s a b -> Signal (a, b)
serverTaskProcessed Server s a b
server)
serverTotalInputWaitTime :: Server s a b -> Event Double
serverTotalInputWaitTime :: Server s a b -> Event Double
serverTotalInputWaitTime Server s a b
server =
(Point -> IO Double) -> Event Double
forall a. (Point -> IO a) -> Event a
Event ((Point -> IO Double) -> Event Double)
-> (Point -> IO Double) -> Event Double
forall a b. (a -> b) -> a -> b
$ \Point
p -> IORef Double -> IO Double
forall a. IORef a -> IO a
readIORef (Server s a b -> IORef Double
forall s a b. Server s a b -> IORef Double
serverTotalInputWaitTimeRef Server s a b
server)
serverTotalInputWaitTimeChanged :: Server s a b -> Signal Double
serverTotalInputWaitTimeChanged :: Server s a b -> Signal Double
serverTotalInputWaitTimeChanged Server s a b
server =
(() -> Event Double) -> Signal () -> Signal Double
forall a b. (a -> Event b) -> Signal a -> Signal b
mapSignalM (Event Double -> () -> Event Double
forall a b. a -> b -> a
const (Event Double -> () -> Event Double)
-> Event Double -> () -> Event Double
forall a b. (a -> b) -> a -> b
$ Server s a b -> Event Double
forall s a b. Server s a b -> Event Double
serverTotalInputWaitTime Server s a b
server) (Server s a b -> Signal ()
forall s a b. Server s a b -> Signal ()
serverTotalInputWaitTimeChanged_ Server s a b
server)
serverTotalInputWaitTimeChanged_ :: Server s a b -> Signal ()
serverTotalInputWaitTimeChanged_ :: Server s a b -> Signal ()
serverTotalInputWaitTimeChanged_ Server s a b
server =
(a -> ()) -> Signal a -> Signal ()
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (() -> a -> ()
forall a b. a -> b -> a
const ()) (Server s a b -> Signal a
forall s a b. Server s a b -> Signal a
serverInputReceived Server s a b
server)
serverTotalProcessingTime :: Server s a b -> Event Double
serverTotalProcessingTime :: Server s a b -> Event Double
serverTotalProcessingTime Server s a b
server =
(Point -> IO Double) -> Event Double
forall a. (Point -> IO a) -> Event a
Event ((Point -> IO Double) -> Event Double)
-> (Point -> IO Double) -> Event Double
forall a b. (a -> b) -> a -> b
$ \Point
p -> IORef Double -> IO Double
forall a. IORef a -> IO a
readIORef (Server s a b -> IORef Double
forall s a b. Server s a b -> IORef Double
serverTotalProcessingTimeRef Server s a b
server)
serverTotalProcessingTimeChanged :: Server s a b -> Signal Double
serverTotalProcessingTimeChanged :: Server s a b -> Signal Double
serverTotalProcessingTimeChanged Server s a b
server =
(() -> Event Double) -> Signal () -> Signal Double
forall a b. (a -> Event b) -> Signal a -> Signal b
mapSignalM (Event Double -> () -> Event Double
forall a b. a -> b -> a
const (Event Double -> () -> Event Double)
-> Event Double -> () -> Event Double
forall a b. (a -> b) -> a -> b
$ Server s a b -> Event Double
forall s a b. Server s a b -> Event Double
serverTotalProcessingTime Server s a b
server) (Server s a b -> Signal ()
forall s a b. Server s a b -> Signal ()
serverTotalProcessingTimeChanged_ Server s a b
server)
serverTotalProcessingTimeChanged_ :: Server s a b -> Signal ()
serverTotalProcessingTimeChanged_ :: Server s a b -> Signal ()
serverTotalProcessingTimeChanged_ Server s a b
server =
((a, b) -> ()) -> Signal (a, b) -> Signal ()
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (() -> (a, b) -> ()
forall a b. a -> b -> a
const ()) (Server s a b -> Signal (a, b)
forall s a b. Server s a b -> Signal (a, b)
serverTaskProcessed Server s a b
server)
serverTotalOutputWaitTime :: Server s a b -> Event Double
serverTotalOutputWaitTime :: Server s a b -> Event Double
serverTotalOutputWaitTime Server s a b
server =
(Point -> IO Double) -> Event Double
forall a. (Point -> IO a) -> Event a
Event ((Point -> IO Double) -> Event Double)
-> (Point -> IO Double) -> Event Double
forall a b. (a -> b) -> a -> b
$ \Point
p -> IORef Double -> IO Double
forall a. IORef a -> IO a
readIORef (Server s a b -> IORef Double
forall s a b. Server s a b -> IORef Double
serverTotalOutputWaitTimeRef Server s a b
server)
serverTotalOutputWaitTimeChanged :: Server s a b -> Signal Double
serverTotalOutputWaitTimeChanged :: Server s a b -> Signal Double
serverTotalOutputWaitTimeChanged Server s a b
server =
(() -> Event Double) -> Signal () -> Signal Double
forall a b. (a -> Event b) -> Signal a -> Signal b
mapSignalM (Event Double -> () -> Event Double
forall a b. a -> b -> a
const (Event Double -> () -> Event Double)
-> Event Double -> () -> Event Double
forall a b. (a -> b) -> a -> b
$ Server s a b -> Event Double
forall s a b. Server s a b -> Event Double
serverTotalOutputWaitTime Server s a b
server) (Server s a b -> Signal ()
forall s a b. Server s a b -> Signal ()
serverTotalOutputWaitTimeChanged_ Server s a b
server)
serverTotalOutputWaitTimeChanged_ :: Server s a b -> Signal ()
serverTotalOutputWaitTimeChanged_ :: Server s a b -> Signal ()
serverTotalOutputWaitTimeChanged_ Server s a b
server =
((a, b) -> ()) -> Signal (a, b) -> Signal ()
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (() -> (a, b) -> ()
forall a b. a -> b -> a
const ()) (Server s a b -> Signal (a, b)
forall s a b. Server s a b -> Signal (a, b)
serverOutputProvided Server s a b
server)
serverTotalPreemptionTime :: Server s a b -> Event Double
serverTotalPreemptionTime :: Server s a b -> Event Double
serverTotalPreemptionTime Server s a b
server =
(Point -> IO Double) -> Event Double
forall a. (Point -> IO a) -> Event a
Event ((Point -> IO Double) -> Event Double)
-> (Point -> IO Double) -> Event Double
forall a b. (a -> b) -> a -> b
$ \Point
p -> IORef Double -> IO Double
forall a. IORef a -> IO a
readIORef (Server s a b -> IORef Double
forall s a b. Server s a b -> IORef Double
serverTotalPreemptionTimeRef Server s a b
server)
serverTotalPreemptionTimeChanged :: Server s a b -> Signal Double
serverTotalPreemptionTimeChanged :: Server s a b -> Signal Double
serverTotalPreemptionTimeChanged Server s a b
server =
(() -> Event Double) -> Signal () -> Signal Double
forall a b. (a -> Event b) -> Signal a -> Signal b
mapSignalM (Event Double -> () -> Event Double
forall a b. a -> b -> a
const (Event Double -> () -> Event Double)
-> Event Double -> () -> Event Double
forall a b. (a -> b) -> a -> b
$ Server s a b -> Event Double
forall s a b. Server s a b -> Event Double
serverTotalPreemptionTime Server s a b
server) (Server s a b -> Signal ()
forall s a b. Server s a b -> Signal ()
serverTotalPreemptionTimeChanged_ Server s a b
server)
serverTotalPreemptionTimeChanged_ :: Server s a b -> Signal ()
serverTotalPreemptionTimeChanged_ :: Server s a b -> Signal ()
serverTotalPreemptionTimeChanged_ Server s a b
server =
(a -> ()) -> Signal a -> Signal ()
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (() -> a -> ()
forall a b. a -> b -> a
const ()) (Server s a b -> Signal a
forall s a b. Server s a b -> Signal a
serverTaskPreemptionEnding Server s a b
server)
serverInputWaitTime :: Server s a b -> Event (SamplingStats Double)
serverInputWaitTime :: Server s a b -> Event (SamplingStats Double)
serverInputWaitTime Server s a b
server =
(Point -> IO (SamplingStats Double))
-> Event (SamplingStats Double)
forall a. (Point -> IO a) -> Event a
Event ((Point -> IO (SamplingStats Double))
-> Event (SamplingStats Double))
-> (Point -> IO (SamplingStats Double))
-> Event (SamplingStats Double)
forall a b. (a -> b) -> a -> b
$ \Point
p -> IORef (SamplingStats Double) -> IO (SamplingStats Double)
forall a. IORef a -> IO a
readIORef (Server s a b -> IORef (SamplingStats Double)
forall s a b. Server s a b -> IORef (SamplingStats Double)
serverInputWaitTimeRef Server s a b
server)
serverInputWaitTimeChanged :: Server s a b -> Signal (SamplingStats Double)
serverInputWaitTimeChanged :: Server s a b -> Signal (SamplingStats Double)
serverInputWaitTimeChanged Server s a b
server =
(() -> Event (SamplingStats Double))
-> Signal () -> Signal (SamplingStats Double)
forall a b. (a -> Event b) -> Signal a -> Signal b
mapSignalM (Event (SamplingStats Double) -> () -> Event (SamplingStats Double)
forall a b. a -> b -> a
const (Event (SamplingStats Double)
-> () -> Event (SamplingStats Double))
-> Event (SamplingStats Double)
-> ()
-> Event (SamplingStats Double)
forall a b. (a -> b) -> a -> b
$ Server s a b -> Event (SamplingStats Double)
forall s a b. Server s a b -> Event (SamplingStats Double)
serverInputWaitTime Server s a b
server) (Server s a b -> Signal ()
forall s a b. Server s a b -> Signal ()
serverInputWaitTimeChanged_ Server s a b
server)
serverInputWaitTimeChanged_ :: Server s a b -> Signal ()
serverInputWaitTimeChanged_ :: Server s a b -> Signal ()
serverInputWaitTimeChanged_ Server s a b
server =
(a -> ()) -> Signal a -> Signal ()
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (() -> a -> ()
forall a b. a -> b -> a
const ()) (Server s a b -> Signal a
forall s a b. Server s a b -> Signal a
serverInputReceived Server s a b
server)
serverProcessingTime :: Server s a b -> Event (SamplingStats Double)
serverProcessingTime :: Server s a b -> Event (SamplingStats Double)
serverProcessingTime Server s a b
server =
(Point -> IO (SamplingStats Double))
-> Event (SamplingStats Double)
forall a. (Point -> IO a) -> Event a
Event ((Point -> IO (SamplingStats Double))
-> Event (SamplingStats Double))
-> (Point -> IO (SamplingStats Double))
-> Event (SamplingStats Double)
forall a b. (a -> b) -> a -> b
$ \Point
p -> IORef (SamplingStats Double) -> IO (SamplingStats Double)
forall a. IORef a -> IO a
readIORef (Server s a b -> IORef (SamplingStats Double)
forall s a b. Server s a b -> IORef (SamplingStats Double)
serverProcessingTimeRef Server s a b
server)
serverProcessingTimeChanged :: Server s a b -> Signal (SamplingStats Double)
serverProcessingTimeChanged :: Server s a b -> Signal (SamplingStats Double)
serverProcessingTimeChanged Server s a b
server =
(() -> Event (SamplingStats Double))
-> Signal () -> Signal (SamplingStats Double)
forall a b. (a -> Event b) -> Signal a -> Signal b
mapSignalM (Event (SamplingStats Double) -> () -> Event (SamplingStats Double)
forall a b. a -> b -> a
const (Event (SamplingStats Double)
-> () -> Event (SamplingStats Double))
-> Event (SamplingStats Double)
-> ()
-> Event (SamplingStats Double)
forall a b. (a -> b) -> a -> b
$ Server s a b -> Event (SamplingStats Double)
forall s a b. Server s a b -> Event (SamplingStats Double)
serverProcessingTime Server s a b
server) (Server s a b -> Signal ()
forall s a b. Server s a b -> Signal ()
serverProcessingTimeChanged_ Server s a b
server)
serverProcessingTimeChanged_ :: Server s a b -> Signal ()
serverProcessingTimeChanged_ :: Server s a b -> Signal ()
serverProcessingTimeChanged_ Server s a b
server =
((a, b) -> ()) -> Signal (a, b) -> Signal ()
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (() -> (a, b) -> ()
forall a b. a -> b -> a
const ()) (Server s a b -> Signal (a, b)
forall s a b. Server s a b -> Signal (a, b)
serverTaskProcessed Server s a b
server)
serverOutputWaitTime :: Server s a b -> Event (SamplingStats Double)
serverOutputWaitTime :: Server s a b -> Event (SamplingStats Double)
serverOutputWaitTime Server s a b
server =
(Point -> IO (SamplingStats Double))
-> Event (SamplingStats Double)
forall a. (Point -> IO a) -> Event a
Event ((Point -> IO (SamplingStats Double))
-> Event (SamplingStats Double))
-> (Point -> IO (SamplingStats Double))
-> Event (SamplingStats Double)
forall a b. (a -> b) -> a -> b
$ \Point
p -> IORef (SamplingStats Double) -> IO (SamplingStats Double)
forall a. IORef a -> IO a
readIORef (Server s a b -> IORef (SamplingStats Double)
forall s a b. Server s a b -> IORef (SamplingStats Double)
serverOutputWaitTimeRef Server s a b
server)
serverOutputWaitTimeChanged :: Server s a b -> Signal (SamplingStats Double)
serverOutputWaitTimeChanged :: Server s a b -> Signal (SamplingStats Double)
serverOutputWaitTimeChanged Server s a b
server =
(() -> Event (SamplingStats Double))
-> Signal () -> Signal (SamplingStats Double)
forall a b. (a -> Event b) -> Signal a -> Signal b
mapSignalM (Event (SamplingStats Double) -> () -> Event (SamplingStats Double)
forall a b. a -> b -> a
const (Event (SamplingStats Double)
-> () -> Event (SamplingStats Double))
-> Event (SamplingStats Double)
-> ()
-> Event (SamplingStats Double)
forall a b. (a -> b) -> a -> b
$ Server s a b -> Event (SamplingStats Double)
forall s a b. Server s a b -> Event (SamplingStats Double)
serverOutputWaitTime Server s a b
server) (Server s a b -> Signal ()
forall s a b. Server s a b -> Signal ()
serverOutputWaitTimeChanged_ Server s a b
server)
serverOutputWaitTimeChanged_ :: Server s a b -> Signal ()
serverOutputWaitTimeChanged_ :: Server s a b -> Signal ()
serverOutputWaitTimeChanged_ Server s a b
server =
((a, b) -> ()) -> Signal (a, b) -> Signal ()
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (() -> (a, b) -> ()
forall a b. a -> b -> a
const ()) (Server s a b -> Signal (a, b)
forall s a b. Server s a b -> Signal (a, b)
serverOutputProvided Server s a b
server)
serverPreemptionTime :: Server s a b -> Event (SamplingStats Double)
serverPreemptionTime :: Server s a b -> Event (SamplingStats Double)
serverPreemptionTime Server s a b
server =
(Point -> IO (SamplingStats Double))
-> Event (SamplingStats Double)
forall a. (Point -> IO a) -> Event a
Event ((Point -> IO (SamplingStats Double))
-> Event (SamplingStats Double))
-> (Point -> IO (SamplingStats Double))
-> Event (SamplingStats Double)
forall a b. (a -> b) -> a -> b
$ \Point
p -> IORef (SamplingStats Double) -> IO (SamplingStats Double)
forall a. IORef a -> IO a
readIORef (Server s a b -> IORef (SamplingStats Double)
forall s a b. Server s a b -> IORef (SamplingStats Double)
serverPreemptionTimeRef Server s a b
server)
serverPreemptionTimeChanged :: Server s a b -> Signal (SamplingStats Double)
serverPreemptionTimeChanged :: Server s a b -> Signal (SamplingStats Double)
serverPreemptionTimeChanged Server s a b
server =
(() -> Event (SamplingStats Double))
-> Signal () -> Signal (SamplingStats Double)
forall a b. (a -> Event b) -> Signal a -> Signal b
mapSignalM (Event (SamplingStats Double) -> () -> Event (SamplingStats Double)
forall a b. a -> b -> a
const (Event (SamplingStats Double)
-> () -> Event (SamplingStats Double))
-> Event (SamplingStats Double)
-> ()
-> Event (SamplingStats Double)
forall a b. (a -> b) -> a -> b
$ Server s a b -> Event (SamplingStats Double)
forall s a b. Server s a b -> Event (SamplingStats Double)
serverPreemptionTime Server s a b
server) (Server s a b -> Signal ()
forall s a b. Server s a b -> Signal ()
serverPreemptionTimeChanged_ Server s a b
server)
serverPreemptionTimeChanged_ :: Server s a b -> Signal ()
serverPreemptionTimeChanged_ :: Server s a b -> Signal ()
serverPreemptionTimeChanged_ Server s a b
server =
(a -> ()) -> Signal a -> Signal ()
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (() -> a -> ()
forall a b. a -> b -> a
const ()) (Server s a b -> Signal a
forall s a b. Server s a b -> Signal a
serverTaskPreemptionEnding Server s a b
server)
serverInputWaitFactor :: Server s a b -> Event Double
serverInputWaitFactor :: Server s a b -> Event Double
serverInputWaitFactor Server s a b
server =
(Point -> IO Double) -> Event Double
forall a. (Point -> IO a) -> Event a
Event ((Point -> IO Double) -> Event Double)
-> (Point -> IO Double) -> Event Double
forall a b. (a -> b) -> a -> b
$ \Point
p ->
do Double
x1 <- IORef Double -> IO Double
forall a. IORef a -> IO a
readIORef (Server s a b -> IORef Double
forall s a b. Server s a b -> IORef Double
serverTotalInputWaitTimeRef Server s a b
server)
Double
x2 <- IORef Double -> IO Double
forall a. IORef a -> IO a
readIORef (Server s a b -> IORef Double
forall s a b. Server s a b -> IORef Double
serverTotalProcessingTimeRef Server s a b
server)
Double
x3 <- IORef Double -> IO Double
forall a. IORef a -> IO a
readIORef (Server s a b -> IORef Double
forall s a b. Server s a b -> IORef Double
serverTotalOutputWaitTimeRef Server s a b
server)
Double
x4 <- IORef Double -> IO Double
forall a. IORef a -> IO a
readIORef (Server s a b -> IORef Double
forall s a b. Server s a b -> IORef Double
serverTotalPreemptionTimeRef Server s a b
server)
Double -> IO Double
forall (m :: * -> *) a. Monad m => a -> m a
return (Double
x1 Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/ (Double
x1 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
x2 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
x3 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
x4))
serverInputWaitFactorChanged :: Server s a b -> Signal Double
serverInputWaitFactorChanged :: Server s a b -> Signal Double
serverInputWaitFactorChanged Server s a b
server =
(() -> Event Double) -> Signal () -> Signal Double
forall a b. (a -> Event b) -> Signal a -> Signal b
mapSignalM (Event Double -> () -> Event Double
forall a b. a -> b -> a
const (Event Double -> () -> Event Double)
-> Event Double -> () -> Event Double
forall a b. (a -> b) -> a -> b
$ Server s a b -> Event Double
forall s a b. Server s a b -> Event Double
serverInputWaitFactor Server s a b
server) (Server s a b -> Signal ()
forall s a b. Server s a b -> Signal ()
serverInputWaitFactorChanged_ Server s a b
server)
serverInputWaitFactorChanged_ :: Server s a b -> Signal ()
serverInputWaitFactorChanged_ :: Server s a b -> Signal ()
serverInputWaitFactorChanged_ Server s a b
server =
(a -> ()) -> Signal a -> Signal ()
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (() -> a -> ()
forall a b. a -> b -> a
const ()) (Server s a b -> Signal a
forall s a b. Server s a b -> Signal a
serverInputReceived Server s a b
server) Signal () -> Signal () -> Signal ()
forall a. Semigroup a => a -> a -> a
<>
((a, b) -> ()) -> Signal (a, b) -> Signal ()
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (() -> (a, b) -> ()
forall a b. a -> b -> a
const ()) (Server s a b -> Signal (a, b)
forall s a b. Server s a b -> Signal (a, b)
serverTaskProcessed Server s a b
server) Signal () -> Signal () -> Signal ()
forall a. Semigroup a => a -> a -> a
<>
((a, b) -> ()) -> Signal (a, b) -> Signal ()
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (() -> (a, b) -> ()
forall a b. a -> b -> a
const ()) (Server s a b -> Signal (a, b)
forall s a b. Server s a b -> Signal (a, b)
serverOutputProvided Server s a b
server) Signal () -> Signal () -> Signal ()
forall a. Semigroup a => a -> a -> a
<>
(a -> ()) -> Signal a -> Signal ()
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (() -> a -> ()
forall a b. a -> b -> a
const ()) (Server s a b -> Signal a
forall s a b. Server s a b -> Signal a
serverTaskPreemptionEnding Server s a b
server)
serverProcessingFactor :: Server s a b -> Event Double
serverProcessingFactor :: Server s a b -> Event Double
serverProcessingFactor Server s a b
server =
(Point -> IO Double) -> Event Double
forall a. (Point -> IO a) -> Event a
Event ((Point -> IO Double) -> Event Double)
-> (Point -> IO Double) -> Event Double
forall a b. (a -> b) -> a -> b
$ \Point
p ->
do Double
x1 <- IORef Double -> IO Double
forall a. IORef a -> IO a
readIORef (Server s a b -> IORef Double
forall s a b. Server s a b -> IORef Double
serverTotalInputWaitTimeRef Server s a b
server)
Double
x2 <- IORef Double -> IO Double
forall a. IORef a -> IO a
readIORef (Server s a b -> IORef Double
forall s a b. Server s a b -> IORef Double
serverTotalProcessingTimeRef Server s a b
server)
Double
x3 <- IORef Double -> IO Double
forall a. IORef a -> IO a
readIORef (Server s a b -> IORef Double
forall s a b. Server s a b -> IORef Double
serverTotalOutputWaitTimeRef Server s a b
server)
Double
x4 <- IORef Double -> IO Double
forall a. IORef a -> IO a
readIORef (Server s a b -> IORef Double
forall s a b. Server s a b -> IORef Double
serverTotalPreemptionTimeRef Server s a b
server)
Double -> IO Double
forall (m :: * -> *) a. Monad m => a -> m a
return (Double
x2 Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/ (Double
x1 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
x2 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
x3 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
x4))
serverProcessingFactorChanged :: Server s a b -> Signal Double
serverProcessingFactorChanged :: Server s a b -> Signal Double
serverProcessingFactorChanged Server s a b
server =
(() -> Event Double) -> Signal () -> Signal Double
forall a b. (a -> Event b) -> Signal a -> Signal b
mapSignalM (Event Double -> () -> Event Double
forall a b. a -> b -> a
const (Event Double -> () -> Event Double)
-> Event Double -> () -> Event Double
forall a b. (a -> b) -> a -> b
$ Server s a b -> Event Double
forall s a b. Server s a b -> Event Double
serverProcessingFactor Server s a b
server) (Server s a b -> Signal ()
forall s a b. Server s a b -> Signal ()
serverProcessingFactorChanged_ Server s a b
server)
serverProcessingFactorChanged_ :: Server s a b -> Signal ()
serverProcessingFactorChanged_ :: Server s a b -> Signal ()
serverProcessingFactorChanged_ Server s a b
server =
(a -> ()) -> Signal a -> Signal ()
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (() -> a -> ()
forall a b. a -> b -> a
const ()) (Server s a b -> Signal a
forall s a b. Server s a b -> Signal a
serverInputReceived Server s a b
server) Signal () -> Signal () -> Signal ()
forall a. Semigroup a => a -> a -> a
<>
((a, b) -> ()) -> Signal (a, b) -> Signal ()
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (() -> (a, b) -> ()
forall a b. a -> b -> a
const ()) (Server s a b -> Signal (a, b)
forall s a b. Server s a b -> Signal (a, b)
serverTaskProcessed Server s a b
server) Signal () -> Signal () -> Signal ()
forall a. Semigroup a => a -> a -> a
<>
((a, b) -> ()) -> Signal (a, b) -> Signal ()
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (() -> (a, b) -> ()
forall a b. a -> b -> a
const ()) (Server s a b -> Signal (a, b)
forall s a b. Server s a b -> Signal (a, b)
serverOutputProvided Server s a b
server) Signal () -> Signal () -> Signal ()
forall a. Semigroup a => a -> a -> a
<>
(a -> ()) -> Signal a -> Signal ()
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (() -> a -> ()
forall a b. a -> b -> a
const ()) (Server s a b -> Signal a
forall s a b. Server s a b -> Signal a
serverTaskPreemptionEnding Server s a b
server)
serverOutputWaitFactor :: Server s a b -> Event Double
serverOutputWaitFactor :: Server s a b -> Event Double
serverOutputWaitFactor Server s a b
server =
(Point -> IO Double) -> Event Double
forall a. (Point -> IO a) -> Event a
Event ((Point -> IO Double) -> Event Double)
-> (Point -> IO Double) -> Event Double
forall a b. (a -> b) -> a -> b
$ \Point
p ->
do Double
x1 <- IORef Double -> IO Double
forall a. IORef a -> IO a
readIORef (Server s a b -> IORef Double
forall s a b. Server s a b -> IORef Double
serverTotalInputWaitTimeRef Server s a b
server)
Double
x2 <- IORef Double -> IO Double
forall a. IORef a -> IO a
readIORef (Server s a b -> IORef Double
forall s a b. Server s a b -> IORef Double
serverTotalProcessingTimeRef Server s a b
server)
Double
x3 <- IORef Double -> IO Double
forall a. IORef a -> IO a
readIORef (Server s a b -> IORef Double
forall s a b. Server s a b -> IORef Double
serverTotalOutputWaitTimeRef Server s a b
server)
Double
x4 <- IORef Double -> IO Double
forall a. IORef a -> IO a
readIORef (Server s a b -> IORef Double
forall s a b. Server s a b -> IORef Double
serverTotalPreemptionTimeRef Server s a b
server)
Double -> IO Double
forall (m :: * -> *) a. Monad m => a -> m a
return (Double
x3 Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/ (Double
x1 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
x2 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
x3 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
x4))
serverOutputWaitFactorChanged :: Server s a b -> Signal Double
serverOutputWaitFactorChanged :: Server s a b -> Signal Double
serverOutputWaitFactorChanged Server s a b
server =
(() -> Event Double) -> Signal () -> Signal Double
forall a b. (a -> Event b) -> Signal a -> Signal b
mapSignalM (Event Double -> () -> Event Double
forall a b. a -> b -> a
const (Event Double -> () -> Event Double)
-> Event Double -> () -> Event Double
forall a b. (a -> b) -> a -> b
$ Server s a b -> Event Double
forall s a b. Server s a b -> Event Double
serverOutputWaitFactor Server s a b
server) (Server s a b -> Signal ()
forall s a b. Server s a b -> Signal ()
serverOutputWaitFactorChanged_ Server s a b
server)
serverOutputWaitFactorChanged_ :: Server s a b -> Signal ()
serverOutputWaitFactorChanged_ :: Server s a b -> Signal ()
serverOutputWaitFactorChanged_ Server s a b
server =
(a -> ()) -> Signal a -> Signal ()
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (() -> a -> ()
forall a b. a -> b -> a
const ()) (Server s a b -> Signal a
forall s a b. Server s a b -> Signal a
serverInputReceived Server s a b
server) Signal () -> Signal () -> Signal ()
forall a. Semigroup a => a -> a -> a
<>
((a, b) -> ()) -> Signal (a, b) -> Signal ()
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (() -> (a, b) -> ()
forall a b. a -> b -> a
const ()) (Server s a b -> Signal (a, b)
forall s a b. Server s a b -> Signal (a, b)
serverTaskProcessed Server s a b
server) Signal () -> Signal () -> Signal ()
forall a. Semigroup a => a -> a -> a
<>
((a, b) -> ()) -> Signal (a, b) -> Signal ()
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (() -> (a, b) -> ()
forall a b. a -> b -> a
const ()) (Server s a b -> Signal (a, b)
forall s a b. Server s a b -> Signal (a, b)
serverOutputProvided Server s a b
server) Signal () -> Signal () -> Signal ()
forall a. Semigroup a => a -> a -> a
<>
(a -> ()) -> Signal a -> Signal ()
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (() -> a -> ()
forall a b. a -> b -> a
const ()) (Server s a b -> Signal a
forall s a b. Server s a b -> Signal a
serverTaskPreemptionEnding Server s a b
server)
serverPreemptionFactor :: Server s a b -> Event Double
serverPreemptionFactor :: Server s a b -> Event Double
serverPreemptionFactor Server s a b
server =
(Point -> IO Double) -> Event Double
forall a. (Point -> IO a) -> Event a
Event ((Point -> IO Double) -> Event Double)
-> (Point -> IO Double) -> Event Double
forall a b. (a -> b) -> a -> b
$ \Point
p ->
do Double
x1 <- IORef Double -> IO Double
forall a. IORef a -> IO a
readIORef (Server s a b -> IORef Double
forall s a b. Server s a b -> IORef Double
serverTotalInputWaitTimeRef Server s a b
server)
Double
x2 <- IORef Double -> IO Double
forall a. IORef a -> IO a
readIORef (Server s a b -> IORef Double
forall s a b. Server s a b -> IORef Double
serverTotalProcessingTimeRef Server s a b
server)
Double
x3 <- IORef Double -> IO Double
forall a. IORef a -> IO a
readIORef (Server s a b -> IORef Double
forall s a b. Server s a b -> IORef Double
serverTotalOutputWaitTimeRef Server s a b
server)
Double
x4 <- IORef Double -> IO Double
forall a. IORef a -> IO a
readIORef (Server s a b -> IORef Double
forall s a b. Server s a b -> IORef Double
serverTotalPreemptionTimeRef Server s a b
server)
Double -> IO Double
forall (m :: * -> *) a. Monad m => a -> m a
return (Double
x4 Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/ (Double
x1 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
x2 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
x3 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
x4))
serverPreemptionFactorChanged :: Server s a b -> Signal Double
serverPreemptionFactorChanged :: Server s a b -> Signal Double
serverPreemptionFactorChanged Server s a b
server =
(() -> Event Double) -> Signal () -> Signal Double
forall a b. (a -> Event b) -> Signal a -> Signal b
mapSignalM (Event Double -> () -> Event Double
forall a b. a -> b -> a
const (Event Double -> () -> Event Double)
-> Event Double -> () -> Event Double
forall a b. (a -> b) -> a -> b
$ Server s a b -> Event Double
forall s a b. Server s a b -> Event Double
serverPreemptionFactor Server s a b
server) (Server s a b -> Signal ()
forall s a b. Server s a b -> Signal ()
serverPreemptionFactorChanged_ Server s a b
server)
serverPreemptionFactorChanged_ :: Server s a b -> Signal ()
serverPreemptionFactorChanged_ :: Server s a b -> Signal ()
serverPreemptionFactorChanged_ Server s a b
server =
(a -> ()) -> Signal a -> Signal ()
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (() -> a -> ()
forall a b. a -> b -> a
const ()) (Server s a b -> Signal a
forall s a b. Server s a b -> Signal a
serverInputReceived Server s a b
server) Signal () -> Signal () -> Signal ()
forall a. Semigroup a => a -> a -> a
<>
((a, b) -> ()) -> Signal (a, b) -> Signal ()
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (() -> (a, b) -> ()
forall a b. a -> b -> a
const ()) (Server s a b -> Signal (a, b)
forall s a b. Server s a b -> Signal (a, b)
serverTaskProcessed Server s a b
server) Signal () -> Signal () -> Signal ()
forall a. Semigroup a => a -> a -> a
<>
((a, b) -> ()) -> Signal (a, b) -> Signal ()
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (() -> (a, b) -> ()
forall a b. a -> b -> a
const ()) (Server s a b -> Signal (a, b)
forall s a b. Server s a b -> Signal (a, b)
serverOutputProvided Server s a b
server) Signal () -> Signal () -> Signal ()
forall a. Semigroup a => a -> a -> a
<>
(a -> ()) -> Signal a -> Signal ()
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (() -> a -> ()
forall a b. a -> b -> a
const ()) (Server s a b -> Signal a
forall s a b. Server s a b -> Signal a
serverTaskPreemptionEnding Server s a b
server)
serverInputReceived :: Server s a b -> Signal a
serverInputReceived :: Server s a b -> Signal a
serverInputReceived = SignalSource a -> Signal a
forall a. SignalSource a -> Signal a
publishSignal (SignalSource a -> Signal a)
-> (Server s a b -> SignalSource a) -> Server s a b -> Signal a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Server s a b -> SignalSource a
forall s a b. Server s a b -> SignalSource a
serverInputReceivedSource
serverTaskPreemptionBeginning :: Server s a b -> Signal a
serverTaskPreemptionBeginning :: Server s a b -> Signal a
serverTaskPreemptionBeginning = SignalSource a -> Signal a
forall a. SignalSource a -> Signal a
publishSignal (SignalSource a -> Signal a)
-> (Server s a b -> SignalSource a) -> Server s a b -> Signal a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Server s a b -> SignalSource a
forall s a b. Server s a b -> SignalSource a
serverTaskPreemptionBeginningSource
serverTaskPreemptionEnding :: Server s a b -> Signal a
serverTaskPreemptionEnding :: Server s a b -> Signal a
serverTaskPreemptionEnding = SignalSource a -> Signal a
forall a. SignalSource a -> Signal a
publishSignal (SignalSource a -> Signal a)
-> (Server s a b -> SignalSource a) -> Server s a b -> Signal a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Server s a b -> SignalSource a
forall s a b. Server s a b -> SignalSource a
serverTaskPreemptionEndingSource
serverTaskProcessed :: Server s a b -> Signal (a, b)
serverTaskProcessed :: Server s a b -> Signal (a, b)
serverTaskProcessed = SignalSource (a, b) -> Signal (a, b)
forall a. SignalSource a -> Signal a
publishSignal (SignalSource (a, b) -> Signal (a, b))
-> (Server s a b -> SignalSource (a, b))
-> Server s a b
-> Signal (a, b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Server s a b -> SignalSource (a, b)
forall s a b. Server s a b -> SignalSource (a, b)
serverTaskProcessedSource
serverOutputProvided :: Server s a b -> Signal (a, b)
serverOutputProvided :: Server s a b -> Signal (a, b)
serverOutputProvided = SignalSource (a, b) -> Signal (a, b)
forall a. SignalSource a -> Signal a
publishSignal (SignalSource (a, b) -> Signal (a, b))
-> (Server s a b -> SignalSource (a, b))
-> Server s a b
-> Signal (a, b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Server s a b -> SignalSource (a, b)
forall s a b. Server s a b -> SignalSource (a, b)
serverOutputProvidedSource
serverChanged_ :: Server s a b -> Signal ()
serverChanged_ :: Server s a b -> Signal ()
serverChanged_ Server s a b
server =
(a -> ()) -> Signal a -> Signal ()
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (() -> a -> ()
forall a b. a -> b -> a
const ()) (Server s a b -> Signal a
forall s a b. Server s a b -> Signal a
serverInputReceived Server s a b
server) Signal () -> Signal () -> Signal ()
forall a. Semigroup a => a -> a -> a
<>
((a, b) -> ()) -> Signal (a, b) -> Signal ()
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (() -> (a, b) -> ()
forall a b. a -> b -> a
const ()) (Server s a b -> Signal (a, b)
forall s a b. Server s a b -> Signal (a, b)
serverTaskProcessed Server s a b
server) Signal () -> Signal () -> Signal ()
forall a. Semigroup a => a -> a -> a
<>
((a, b) -> ()) -> Signal (a, b) -> Signal ()
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (() -> (a, b) -> ()
forall a b. a -> b -> a
const ()) (Server s a b -> Signal (a, b)
forall s a b. Server s a b -> Signal (a, b)
serverOutputProvided Server s a b
server) Signal () -> Signal () -> Signal ()
forall a. Semigroup a => a -> a -> a
<>
(a -> ()) -> Signal a -> Signal ()
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (() -> a -> ()
forall a b. a -> b -> a
const ()) (Server s a b -> Signal a
forall s a b. Server s a b -> Signal a
serverTaskPreemptionEnding Server s a b
server)
serverSummary :: Server s a b -> Int -> Event ShowS
serverSummary :: Server s a b -> Int -> Event ShowS
serverSummary Server s a b
server Int
indent =
(Point -> IO ShowS) -> Event ShowS
forall a. (Point -> IO a) -> Event a
Event ((Point -> IO ShowS) -> Event ShowS)
-> (Point -> IO ShowS) -> Event ShowS
forall a b. (a -> b) -> a -> b
$ \Point
p ->
do Double
tx1 <- IORef Double -> IO Double
forall a. IORef a -> IO a
readIORef (Server s a b -> IORef Double
forall s a b. Server s a b -> IORef Double
serverTotalInputWaitTimeRef Server s a b
server)
Double
tx2 <- IORef Double -> IO Double
forall a. IORef a -> IO a
readIORef (Server s a b -> IORef Double
forall s a b. Server s a b -> IORef Double
serverTotalProcessingTimeRef Server s a b
server)
Double
tx3 <- IORef Double -> IO Double
forall a. IORef a -> IO a
readIORef (Server s a b -> IORef Double
forall s a b. Server s a b -> IORef Double
serverTotalOutputWaitTimeRef Server s a b
server)
Double
tx4 <- IORef Double -> IO Double
forall a. IORef a -> IO a
readIORef (Server s a b -> IORef Double
forall s a b. Server s a b -> IORef Double
serverTotalPreemptionTimeRef Server s a b
server)
let xf1 :: Double
xf1 = Double
tx1 Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/ (Double
tx1 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
tx2 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
tx3 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
tx4)
xf2 :: Double
xf2 = Double
tx2 Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/ (Double
tx1 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
tx2 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
tx3 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
tx4)
xf3 :: Double
xf3 = Double
tx3 Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/ (Double
tx1 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
tx2 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
tx3 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
tx4)
xf4 :: Double
xf4 = Double
tx4 Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/ (Double
tx1 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
tx3 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
tx3 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
tx4)
SamplingStats Double
xs1 <- IORef (SamplingStats Double) -> IO (SamplingStats Double)
forall a. IORef a -> IO a
readIORef (Server s a b -> IORef (SamplingStats Double)
forall s a b. Server s a b -> IORef (SamplingStats Double)
serverInputWaitTimeRef Server s a b
server)
SamplingStats Double
xs2 <- IORef (SamplingStats Double) -> IO (SamplingStats Double)
forall a. IORef a -> IO a
readIORef (Server s a b -> IORef (SamplingStats Double)
forall s a b. Server s a b -> IORef (SamplingStats Double)
serverProcessingTimeRef Server s a b
server)
SamplingStats Double
xs3 <- IORef (SamplingStats Double) -> IO (SamplingStats Double)
forall a. IORef a -> IO a
readIORef (Server s a b -> IORef (SamplingStats Double)
forall s a b. Server s a b -> IORef (SamplingStats Double)
serverOutputWaitTimeRef Server s a b
server)
SamplingStats Double
xs4 <- IORef (SamplingStats Double) -> IO (SamplingStats Double)
forall a. IORef a -> IO a
readIORef (Server s a b -> IORef (SamplingStats Double)
forall s a b. Server s a b -> IORef (SamplingStats Double)
serverPreemptionTimeRef Server s a b
server)
let tab :: [Char]
tab = Int -> Char -> [Char]
forall a. Int -> a -> [a]
replicate Int
indent Char
' '
ShowS -> IO ShowS
forall (m :: * -> *) a. Monad m => a -> m a
return (ShowS -> IO ShowS) -> ShowS -> IO ShowS
forall a b. (a -> b) -> a -> b
$
[Char] -> ShowS
showString [Char]
tab ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"total input wait time (locked while awaiting the input) = " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> ShowS
forall a. Show a => a -> ShowS
shows Double
tx1 ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"total processing time = " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> ShowS
forall a. Show a => a -> ShowS
shows Double
tx2 ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"total output wait time (locked while delivering the output) = " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> ShowS
forall a. Show a => a -> ShowS
shows Double
tx3 ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n\n" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"total preemption time = " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> ShowS
forall a. Show a => a -> ShowS
shows Double
tx4 ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"input wait factor (from 0 to 1) = " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> ShowS
forall a. Show a => a -> ShowS
shows Double
xf1 ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"processing factor (from 0 to 1) = " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> ShowS
forall a. Show a => a -> ShowS
shows Double
xf2 ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"output wait factor (from 0 to 1) = " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> ShowS
forall a. Show a => a -> ShowS
shows Double
xf3 ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n\n" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"output preemption factor (from 0 to 1) = " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> ShowS
forall a. Show a => a -> ShowS
shows Double
xf4 ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n\n" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"input wait time (locked while awaiting the input):\n\n" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
SamplingStats Double -> Int -> ShowS
forall a. Show a => SamplingStats a -> Int -> ShowS
samplingStatsSummary SamplingStats Double
xs1 (Int
2 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
indent) ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n\n" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"processing time:\n\n" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
SamplingStats Double -> Int -> ShowS
forall a. Show a => SamplingStats a -> Int -> ShowS
samplingStatsSummary SamplingStats Double
xs2 (Int
2 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
indent) ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n\n" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"output wait time (locked while delivering the output):\n\n" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
SamplingStats Double -> Int -> ShowS
forall a. Show a => SamplingStats a -> Int -> ShowS
samplingStatsSummary SamplingStats Double
xs3 (Int
2 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
indent) ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n\n" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"preemption time (waiting for the proceeding after preemption):\n\n" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
SamplingStats Double -> Int -> ShowS
forall a. Show a => SamplingStats a -> Int -> ShowS
samplingStatsSummary SamplingStats Double
xs4 (Int
2 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
indent)
resetServer :: Server s a b -> Event ()
resetServer :: Server s a b -> Event ()
resetServer Server s a b
server =
(Point -> IO ()) -> Event ()
forall a. (Point -> IO a) -> Event a
Event ((Point -> IO ()) -> Event ()) -> (Point -> IO ()) -> Event ()
forall a b. (a -> b) -> a -> b
$ \Point
p ->
do IORef Double -> Double -> IO ()
forall a. IORef a -> a -> IO ()
writeIORef (Server s a b -> IORef Double
forall s a b. Server s a b -> IORef Double
serverTotalInputWaitTimeRef Server s a b
server) Double
0
IORef Double -> Double -> IO ()
forall a. IORef a -> a -> IO ()
writeIORef (Server s a b -> IORef Double
forall s a b. Server s a b -> IORef Double
serverTotalProcessingTimeRef Server s a b
server) Double
0
IORef Double -> Double -> IO ()
forall a. IORef a -> a -> IO ()
writeIORef (Server s a b -> IORef Double
forall s a b. Server s a b -> IORef Double
serverTotalOutputWaitTimeRef Server s a b
server) Double
0
IORef Double -> Double -> IO ()
forall a. IORef a -> a -> IO ()
writeIORef (Server s a b -> IORef Double
forall s a b. Server s a b -> IORef Double
serverTotalPreemptionTimeRef Server s a b
server) Double
0
IORef (SamplingStats Double) -> SamplingStats Double -> IO ()
forall a. IORef a -> a -> IO ()
writeIORef (Server s a b -> IORef (SamplingStats Double)
forall s a b. Server s a b -> IORef (SamplingStats Double)
serverInputWaitTimeRef Server s a b
server) SamplingStats Double
forall a. Monoid a => a
mempty
IORef (SamplingStats Double) -> SamplingStats Double -> IO ()
forall a. IORef a -> a -> IO ()
writeIORef (Server s a b -> IORef (SamplingStats Double)
forall s a b. Server s a b -> IORef (SamplingStats Double)
serverProcessingTimeRef Server s a b
server) SamplingStats Double
forall a. Monoid a => a
mempty
IORef (SamplingStats Double) -> SamplingStats Double -> IO ()
forall a. IORef a -> a -> IO ()
writeIORef (Server s a b -> IORef (SamplingStats Double)
forall s a b. Server s a b -> IORef (SamplingStats Double)
serverOutputWaitTimeRef Server s a b
server) SamplingStats Double
forall a. Monoid a => a
mempty
IORef (SamplingStats Double) -> SamplingStats Double -> IO ()
forall a. IORef a -> a -> IO ()
writeIORef (Server s a b -> IORef (SamplingStats Double)
forall s a b. Server s a b -> IORef (SamplingStats Double)
serverPreemptionTimeRef Server s a b
server) SamplingStats Double
forall a. Monoid a => a
mempty