{-# LANGUAGE FlexibleContexts #-}
module Simulation.Aivika.Trans.Queue
(
FCFSQueue,
LCFSQueue,
SIROQueue,
PriorityQueue,
Queue,
newFCFSQueue,
newLCFSQueue,
newSIROQueue,
newPriorityQueue,
newQueue,
enqueueStrategy,
enqueueStoringStrategy,
dequeueStrategy,
queueNull,
queueFull,
queueMaxCount,
queueCount,
queueCountStats,
enqueueCount,
enqueueLostCount,
enqueueStoreCount,
dequeueCount,
dequeueExtractCount,
queueLoadFactor,
enqueueRate,
enqueueStoreRate,
dequeueRate,
dequeueExtractRate,
queueWaitTime,
queueTotalWaitTime,
enqueueWaitTime,
dequeueWaitTime,
queueRate,
dequeue,
dequeueWithOutputPriority,
tryDequeue,
enqueue,
enqueueWithInputPriority,
enqueueWithStoringPriority,
enqueueWithInputStoringPriorities,
tryEnqueue,
tryEnqueueWithStoringPriority,
enqueueOrLost,
enqueueOrLost_,
enqueueWithStoringPriorityOrLost,
enqueueWithStoringPriorityOrLost_,
queueDelete,
queueDelete_,
queueDeleteBy,
queueDeleteBy_,
queueContains,
queueContainsBy,
clearQueue,
resetQueue,
waitWhileFullQueue,
queueSummary,
queueNullChanged,
queueNullChanged_,
queueFullChanged,
queueFullChanged_,
queueCountChanged,
queueCountChanged_,
enqueueCountChanged,
enqueueCountChanged_,
enqueueLostCountChanged,
enqueueLostCountChanged_,
enqueueStoreCountChanged,
enqueueStoreCountChanged_,
dequeueCountChanged,
dequeueCountChanged_,
dequeueExtractCountChanged,
dequeueExtractCountChanged_,
queueLoadFactorChanged,
queueLoadFactorChanged_,
queueWaitTimeChanged,
queueWaitTimeChanged_,
queueTotalWaitTimeChanged,
queueTotalWaitTimeChanged_,
enqueueWaitTimeChanged,
enqueueWaitTimeChanged_,
dequeueWaitTimeChanged,
dequeueWaitTimeChanged_,
queueRateChanged,
queueRateChanged_,
enqueueInitiated,
enqueueStored,
enqueueLost,
dequeueRequested,
dequeueExtracted,
queueChanged_) where
import Data.Monoid
import Data.Maybe
import Control.Monad
import Control.Monad.Trans
import Simulation.Aivika.Trans.Ref.Base
import Simulation.Aivika.Trans.DES
import Simulation.Aivika.Trans.Internal.Specs
import Simulation.Aivika.Trans.Internal.Parameter
import Simulation.Aivika.Trans.Internal.Simulation
import Simulation.Aivika.Trans.Internal.Dynamics
import Simulation.Aivika.Trans.Internal.Event
import Simulation.Aivika.Trans.Internal.Process
import Simulation.Aivika.Trans.Signal
import Simulation.Aivika.Trans.Resource.Base
import Simulation.Aivika.Trans.QueueStrategy
import Simulation.Aivika.Trans.Statistics
type FCFSQueue m a = Queue m FCFS FCFS FCFS a
type LCFSQueue m a = Queue m FCFS LCFS FCFS a
type SIROQueue m a = Queue m FCFS SIRO FCFS a
type PriorityQueue m a = Queue m FCFS StaticPriorities FCFS a
data Queue m si sm so a =
Queue { forall (m :: * -> *) si sm so a. Queue m si sm so a -> Int
queueMaxCount :: Int,
forall (m :: * -> *) si sm so a. Queue m si sm so a -> si
enqueueStrategy :: si,
forall (m :: * -> *) si sm so a. Queue m si sm so a -> sm
enqueueStoringStrategy :: sm,
forall (m :: * -> *) si sm so a. Queue m si sm so a -> so
dequeueStrategy :: so,
forall (m :: * -> *) si sm so a.
Queue m si sm so a -> Resource m si
enqueueRes :: Resource m si,
forall (m :: * -> *) si sm so a.
Queue m si sm so a -> StrategyQueue m sm (QueueItem a)
queueStore :: StrategyQueue m sm (QueueItem a),
forall (m :: * -> *) si sm so a.
Queue m si sm so a -> Resource m so
dequeueRes :: Resource m so,
forall (m :: * -> *) si sm so a. Queue m si sm so a -> Ref m Int
queueCountRef :: Ref m Int,
forall (m :: * -> *) si sm so a.
Queue m si sm so a -> Ref m (TimingStats Int)
queueCountStatsRef :: Ref m (TimingStats Int),
forall (m :: * -> *) si sm so a. Queue m si sm so a -> Ref m Int
enqueueCountRef :: Ref m Int,
forall (m :: * -> *) si sm so a. Queue m si sm so a -> Ref m Int
enqueueLostCountRef :: Ref m Int,
forall (m :: * -> *) si sm so a. Queue m si sm so a -> Ref m Int
enqueueStoreCountRef :: Ref m Int,
forall (m :: * -> *) si sm so a. Queue m si sm so a -> Ref m Int
dequeueCountRef :: Ref m Int,
:: Ref m Int,
forall (m :: * -> *) si sm so a.
Queue m si sm so a -> Ref m (SamplingStats Double)
queueWaitTimeRef :: Ref m (SamplingStats Double),
forall (m :: * -> *) si sm so a.
Queue m si sm so a -> Ref m (SamplingStats Double)
queueTotalWaitTimeRef :: Ref m (SamplingStats Double),
forall (m :: * -> *) si sm so a.
Queue m si sm so a -> Ref m (SamplingStats Double)
enqueueWaitTimeRef :: Ref m (SamplingStats Double),
forall (m :: * -> *) si sm so a.
Queue m si sm so a -> Ref m (SamplingStats Double)
dequeueWaitTimeRef :: Ref m (SamplingStats Double),
forall (m :: * -> *) si sm so a.
Queue m si sm so a -> SignalSource m a
enqueueInitiatedSource :: SignalSource m a,
forall (m :: * -> *) si sm so a.
Queue m si sm so a -> SignalSource m a
enqueueLostSource :: SignalSource m a,
forall (m :: * -> *) si sm so a.
Queue m si sm so a -> SignalSource m a
enqueueStoredSource :: SignalSource m a,
forall (m :: * -> *) si sm so a.
Queue m si sm so a -> SignalSource m ()
dequeueRequestedSource :: SignalSource m (),
:: SignalSource m a }
data QueueItem a =
QueueItem { forall a. QueueItem a -> a
itemValue :: a,
forall a. QueueItem a -> Double
itemInputTime :: Double,
forall a. QueueItem a -> Double
itemStoringTime :: Double
}
newFCFSQueue :: MonadDES m => Int -> Event m (FCFSQueue m a)
{-# INLINABLE newFCFSQueue #-}
newFCFSQueue :: forall (m :: * -> *) a.
MonadDES m =>
Int -> Event m (FCFSQueue m a)
newFCFSQueue = forall (m :: * -> *) si sm so a.
(MonadDES m, QueueStrategy m si, QueueStrategy m sm,
QueueStrategy m so) =>
si -> sm -> so -> Int -> Event m (Queue m si sm so a)
newQueue FCFS
FCFS FCFS
FCFS FCFS
FCFS
newLCFSQueue :: MonadDES m => Int -> Event m (LCFSQueue m a)
{-# INLINABLE newLCFSQueue #-}
newLCFSQueue :: forall (m :: * -> *) a.
MonadDES m =>
Int -> Event m (LCFSQueue m a)
newLCFSQueue = forall (m :: * -> *) si sm so a.
(MonadDES m, QueueStrategy m si, QueueStrategy m sm,
QueueStrategy m so) =>
si -> sm -> so -> Int -> Event m (Queue m si sm so a)
newQueue FCFS
FCFS LCFS
LCFS FCFS
FCFS
newSIROQueue :: (MonadDES m, QueueStrategy m SIRO) => Int -> Event m (SIROQueue m a)
{-# INLINABLE newSIROQueue #-}
newSIROQueue :: forall (m :: * -> *) a.
(MonadDES m, QueueStrategy m SIRO) =>
Int -> Event m (SIROQueue m a)
newSIROQueue = forall (m :: * -> *) si sm so a.
(MonadDES m, QueueStrategy m si, QueueStrategy m sm,
QueueStrategy m so) =>
si -> sm -> so -> Int -> Event m (Queue m si sm so a)
newQueue FCFS
FCFS SIRO
SIRO FCFS
FCFS
newPriorityQueue :: (MonadDES m, QueueStrategy m StaticPriorities) => Int -> Event m (PriorityQueue m a)
{-# INLINABLE newPriorityQueue #-}
newPriorityQueue :: forall (m :: * -> *) a.
(MonadDES m, QueueStrategy m StaticPriorities) =>
Int -> Event m (PriorityQueue m a)
newPriorityQueue = forall (m :: * -> *) si sm so a.
(MonadDES m, QueueStrategy m si, QueueStrategy m sm,
QueueStrategy m so) =>
si -> sm -> so -> Int -> Event m (Queue m si sm so a)
newQueue FCFS
FCFS StaticPriorities
StaticPriorities FCFS
FCFS
newQueue :: (MonadDES m,
QueueStrategy m si,
QueueStrategy m sm,
QueueStrategy m so) =>
si
-> sm
-> so
-> Int
-> Event m (Queue m si sm so a)
{-# INLINABLE newQueue #-}
newQueue :: forall (m :: * -> *) si sm so a.
(MonadDES m, QueueStrategy m si, QueueStrategy m sm,
QueueStrategy m so) =>
si -> sm -> so -> Int -> Event m (Queue m si sm so a)
newQueue si
si sm
sm so
so Int
count =
do Double
t <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
DynamicsLift t m =>
Dynamics m a -> t m a
liftDynamics forall (m :: * -> *). Monad m => Dynamics m Double
time
Ref m Int
i <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
SimulationLift t m =>
Simulation m a -> t m a
liftSimulation forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadRef m => a -> Simulation m (Ref m a)
newRef Int
0
Ref m (TimingStats Int)
is <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
SimulationLift t m =>
Simulation m a -> t m a
liftSimulation forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadRef m => a -> Simulation m (Ref m a)
newRef forall a b. (a -> b) -> a -> b
$ forall a. TimingData a => Double -> a -> TimingStats a
returnTimingStats Double
t Int
0
Ref m Int
ci <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
SimulationLift t m =>
Simulation m a -> t m a
liftSimulation forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadRef m => a -> Simulation m (Ref m a)
newRef Int
0
Ref m Int
cl <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
SimulationLift t m =>
Simulation m a -> t m a
liftSimulation forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadRef m => a -> Simulation m (Ref m a)
newRef Int
0
Ref m Int
cm <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
SimulationLift t m =>
Simulation m a -> t m a
liftSimulation forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadRef m => a -> Simulation m (Ref m a)
newRef Int
0
Ref m Int
cr <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
SimulationLift t m =>
Simulation m a -> t m a
liftSimulation forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadRef m => a -> Simulation m (Ref m a)
newRef Int
0
Ref m Int
co <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
SimulationLift t m =>
Simulation m a -> t m a
liftSimulation forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadRef m => a -> Simulation m (Ref m a)
newRef Int
0
Resource m si
ri <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
SimulationLift t m =>
Simulation m a -> t m a
liftSimulation forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) s.
(MonadDES m, QueueStrategy m s) =>
s -> Int -> Maybe Int -> Simulation m (Resource m s)
newResourceWithMaxCount si
si Int
count (forall a. a -> Maybe a
Just Int
count)
StrategyQueue m sm (QueueItem a)
qm <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
SimulationLift t m =>
Simulation m a -> t m a
liftSimulation forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) s a.
QueueStrategy m s =>
s -> Simulation m (StrategyQueue m s a)
newStrategyQueue sm
sm
Resource m so
ro <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
SimulationLift t m =>
Simulation m a -> t m a
liftSimulation forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) s.
(MonadDES m, QueueStrategy m s) =>
s -> Int -> Maybe Int -> Simulation m (Resource m s)
newResourceWithMaxCount so
so Int
0 (forall a. a -> Maybe a
Just Int
count)
Ref m (SamplingStats Double)
w <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
SimulationLift t m =>
Simulation m a -> t m a
liftSimulation forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadRef m => a -> Simulation m (Ref m a)
newRef forall a. Monoid a => a
mempty
Ref m (SamplingStats Double)
wt <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
SimulationLift t m =>
Simulation m a -> t m a
liftSimulation forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadRef m => a -> Simulation m (Ref m a)
newRef forall a. Monoid a => a
mempty
Ref m (SamplingStats Double)
wi <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
SimulationLift t m =>
Simulation m a -> t m a
liftSimulation forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadRef m => a -> Simulation m (Ref m a)
newRef forall a. Monoid a => a
mempty
Ref m (SamplingStats Double)
wo <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
SimulationLift t m =>
Simulation m a -> t m a
liftSimulation forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadRef m => a -> Simulation m (Ref m a)
newRef forall a. Monoid a => a
mempty
SignalSource m a
s1 <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
SimulationLift t m =>
Simulation m a -> t m a
liftSimulation forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a.
MonadDES m =>
Simulation m (SignalSource m a)
newSignalSource
SignalSource m a
s2 <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
SimulationLift t m =>
Simulation m a -> t m a
liftSimulation forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a.
MonadDES m =>
Simulation m (SignalSource m a)
newSignalSource
SignalSource m a
s3 <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
SimulationLift t m =>
Simulation m a -> t m a
liftSimulation forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a.
MonadDES m =>
Simulation m (SignalSource m a)
newSignalSource
SignalSource m ()
s4 <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
SimulationLift t m =>
Simulation m a -> t m a
liftSimulation forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a.
MonadDES m =>
Simulation m (SignalSource m a)
newSignalSource
SignalSource m a
s5 <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
SimulationLift t m =>
Simulation m a -> t m a
liftSimulation forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a.
MonadDES m =>
Simulation m (SignalSource m a)
newSignalSource
forall (m :: * -> *) a. Monad m => a -> m a
return Queue { queueMaxCount :: Int
queueMaxCount = Int
count,
enqueueStrategy :: si
enqueueStrategy = si
si,
enqueueStoringStrategy :: sm
enqueueStoringStrategy = sm
sm,
dequeueStrategy :: so
dequeueStrategy = so
so,
enqueueRes :: Resource m si
enqueueRes = Resource m si
ri,
queueStore :: StrategyQueue m sm (QueueItem a)
queueStore = StrategyQueue m sm (QueueItem a)
qm,
dequeueRes :: Resource m so
dequeueRes = Resource m so
ro,
queueCountRef :: Ref m Int
queueCountRef = Ref m Int
i,
queueCountStatsRef :: Ref m (TimingStats Int)
queueCountStatsRef = Ref m (TimingStats Int)
is,
enqueueCountRef :: Ref m Int
enqueueCountRef = Ref m Int
ci,
enqueueLostCountRef :: Ref m Int
enqueueLostCountRef = Ref m Int
cl,
enqueueStoreCountRef :: Ref m Int
enqueueStoreCountRef = Ref m Int
cm,
dequeueCountRef :: Ref m Int
dequeueCountRef = Ref m Int
cr,
dequeueExtractCountRef :: Ref m Int
dequeueExtractCountRef = Ref m Int
co,
queueWaitTimeRef :: Ref m (SamplingStats Double)
queueWaitTimeRef = Ref m (SamplingStats Double)
w,
queueTotalWaitTimeRef :: Ref m (SamplingStats Double)
queueTotalWaitTimeRef = Ref m (SamplingStats Double)
wt,
enqueueWaitTimeRef :: Ref m (SamplingStats Double)
enqueueWaitTimeRef = Ref m (SamplingStats Double)
wi,
dequeueWaitTimeRef :: Ref m (SamplingStats Double)
dequeueWaitTimeRef = Ref m (SamplingStats Double)
wo,
enqueueInitiatedSource :: SignalSource m a
enqueueInitiatedSource = SignalSource m a
s1,
enqueueLostSource :: SignalSource m a
enqueueLostSource = SignalSource m a
s2,
enqueueStoredSource :: SignalSource m a
enqueueStoredSource = SignalSource m a
s3,
dequeueRequestedSource :: SignalSource m ()
dequeueRequestedSource = SignalSource m ()
s4,
dequeueExtractedSource :: SignalSource m a
dequeueExtractedSource = SignalSource m a
s5 }
queueNull :: MonadDES m => Queue m si sm so a -> Event m Bool
{-# INLINABLE queueNull #-}
queueNull :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m Bool
queueNull Queue m si sm so a
q =
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event forall a b. (a -> b) -> a -> b
$ \Point m
p ->
do Int
n <- forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (forall (m :: * -> *) si sm so a. Queue m si sm so a -> Ref m Int
queueCountRef Queue m si sm so a
q)
forall (m :: * -> *) a. Monad m => a -> m a
return (Int
n forall a. Eq a => a -> a -> Bool
== Int
0)
queueNullChanged :: MonadDES m => Queue m si sm so a -> Signal m Bool
{-# INLINABLE queueNullChanged #-}
queueNullChanged :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m Bool
queueNullChanged Queue m si sm so a
q =
forall (m :: * -> *) a b.
MonadDES m =>
(a -> Event m b) -> Signal m a -> Signal m b
mapSignalM (forall a b. a -> b -> a
const forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m Bool
queueNull Queue m si sm so a
q) (forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m ()
queueNullChanged_ Queue m si sm so a
q)
queueNullChanged_ :: MonadDES m => Queue m si sm so a -> Signal m ()
{-# INLINABLE queueNullChanged_ #-}
queueNullChanged_ :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m ()
queueNullChanged_ = forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m ()
queueCountChanged_
queueFull :: MonadDES m => Queue m si sm so a -> Event m Bool
{-# INLINABLE queueFull #-}
queueFull :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m Bool
queueFull Queue m si sm so a
q =
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event forall a b. (a -> b) -> a -> b
$ \Point m
p ->
do Int
n <- forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (forall (m :: * -> *) si sm so a. Queue m si sm so a -> Ref m Int
queueCountRef Queue m si sm so a
q)
forall (m :: * -> *) a. Monad m => a -> m a
return (Int
n forall a. Eq a => a -> a -> Bool
== forall (m :: * -> *) si sm so a. Queue m si sm so a -> Int
queueMaxCount Queue m si sm so a
q)
queueFullChanged :: MonadDES m => Queue m si sm so a -> Signal m Bool
{-# INLINABLE queueFullChanged #-}
queueFullChanged :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m Bool
queueFullChanged Queue m si sm so a
q =
forall (m :: * -> *) a b.
MonadDES m =>
(a -> Event m b) -> Signal m a -> Signal m b
mapSignalM (forall a b. a -> b -> a
const forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m Bool
queueFull Queue m si sm so a
q) (forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m ()
queueFullChanged_ Queue m si sm so a
q)
queueFullChanged_ :: MonadDES m => Queue m si sm so a -> Signal m ()
{-# INLINABLE queueFullChanged_ #-}
queueFullChanged_ :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m ()
queueFullChanged_ = forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m ()
queueCountChanged_
queueCount :: MonadDES m => Queue m si sm so a -> Event m Int
{-# INLINABLE queueCount #-}
queueCount :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m Int
queueCount Queue m si sm so a
q =
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event forall a b. (a -> b) -> a -> b
$ \Point m
p -> forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (forall (m :: * -> *) si sm so a. Queue m si sm so a -> Ref m Int
queueCountRef Queue m si sm so a
q)
queueCountStats :: MonadDES m => Queue m si sm so a -> Event m (TimingStats Int)
{-# INLINABLE queueCountStats #-}
queueCountStats :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m (TimingStats Int)
queueCountStats Queue m si sm so a
q =
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event forall a b. (a -> b) -> a -> b
$ \Point m
p -> forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> Ref m (TimingStats Int)
queueCountStatsRef Queue m si sm so a
q)
queueCountChanged :: MonadDES m => Queue m si sm so a -> Signal m Int
{-# INLINABLE queueCountChanged #-}
queueCountChanged :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m Int
queueCountChanged Queue m si sm so a
q =
forall (m :: * -> *) a b.
MonadDES m =>
(a -> Event m b) -> Signal m a -> Signal m b
mapSignalM (forall a b. a -> b -> a
const forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m Int
queueCount Queue m si sm so a
q) (forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m ()
queueCountChanged_ Queue m si sm so a
q)
queueCountChanged_ :: MonadDES m => Queue m si sm so a -> Signal m ()
{-# INLINABLE queueCountChanged_ #-}
queueCountChanged_ :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m ()
queueCountChanged_ Queue m si sm so a
q =
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (forall a b. a -> b -> a
const ()) (forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m a
enqueueStored Queue m si sm so a
q) forall a. Semigroup a => a -> a -> a
<>
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (forall a b. a -> b -> a
const ()) (forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m a
dequeueExtracted Queue m si sm so a
q)
enqueueCount :: MonadDES m => Queue m si sm so a -> Event m Int
{-# INLINABLE enqueueCount #-}
enqueueCount :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m Int
enqueueCount Queue m si sm so a
q =
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event forall a b. (a -> b) -> a -> b
$ \Point m
p -> forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (forall (m :: * -> *) si sm so a. Queue m si sm so a -> Ref m Int
enqueueCountRef Queue m si sm so a
q)
enqueueCountChanged :: MonadDES m => Queue m si sm so a -> Signal m Int
{-# INLINABLE enqueueCountChanged #-}
enqueueCountChanged :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m Int
enqueueCountChanged Queue m si sm so a
q =
forall (m :: * -> *) a b.
MonadDES m =>
(a -> Event m b) -> Signal m a -> Signal m b
mapSignalM (forall a b. a -> b -> a
const forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m Int
enqueueCount Queue m si sm so a
q) (forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m ()
enqueueCountChanged_ Queue m si sm so a
q)
enqueueCountChanged_ :: MonadDES m => Queue m si sm so a -> Signal m ()
{-# INLINABLE enqueueCountChanged_ #-}
enqueueCountChanged_ :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m ()
enqueueCountChanged_ Queue m si sm so a
q =
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (forall a b. a -> b -> a
const ()) (forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m a
enqueueInitiated Queue m si sm so a
q)
enqueueLostCount :: MonadDES m => Queue m si sm so a -> Event m Int
{-# INLINABLE enqueueLostCount #-}
enqueueLostCount :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m Int
enqueueLostCount Queue m si sm so a
q =
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event forall a b. (a -> b) -> a -> b
$ \Point m
p -> forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (forall (m :: * -> *) si sm so a. Queue m si sm so a -> Ref m Int
enqueueLostCountRef Queue m si sm so a
q)
enqueueLostCountChanged :: MonadDES m => Queue m si sm so a -> Signal m Int
{-# INLINABLE enqueueLostCountChanged #-}
enqueueLostCountChanged :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m Int
enqueueLostCountChanged Queue m si sm so a
q =
forall (m :: * -> *) a b.
MonadDES m =>
(a -> Event m b) -> Signal m a -> Signal m b
mapSignalM (forall a b. a -> b -> a
const forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m Int
enqueueLostCount Queue m si sm so a
q) (forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m ()
enqueueLostCountChanged_ Queue m si sm so a
q)
enqueueLostCountChanged_ :: MonadDES m => Queue m si sm so a -> Signal m ()
{-# INLINABLE enqueueLostCountChanged_ #-}
enqueueLostCountChanged_ :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m ()
enqueueLostCountChanged_ Queue m si sm so a
q =
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (forall a b. a -> b -> a
const ()) (forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m a
enqueueLost Queue m si sm so a
q)
enqueueStoreCount :: MonadDES m => Queue m si sm so a -> Event m Int
{-# INLINABLE enqueueStoreCount #-}
enqueueStoreCount :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m Int
enqueueStoreCount Queue m si sm so a
q =
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event forall a b. (a -> b) -> a -> b
$ \Point m
p -> forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (forall (m :: * -> *) si sm so a. Queue m si sm so a -> Ref m Int
enqueueStoreCountRef Queue m si sm so a
q)
enqueueStoreCountChanged :: MonadDES m => Queue m si sm so a -> Signal m Int
{-# INLINABLE enqueueStoreCountChanged #-}
enqueueStoreCountChanged :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m Int
enqueueStoreCountChanged Queue m si sm so a
q =
forall (m :: * -> *) a b.
MonadDES m =>
(a -> Event m b) -> Signal m a -> Signal m b
mapSignalM (forall a b. a -> b -> a
const forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m Int
enqueueStoreCount Queue m si sm so a
q) (forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m ()
enqueueStoreCountChanged_ Queue m si sm so a
q)
enqueueStoreCountChanged_ :: MonadDES m => Queue m si sm so a -> Signal m ()
{-# INLINABLE enqueueStoreCountChanged_ #-}
enqueueStoreCountChanged_ :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m ()
enqueueStoreCountChanged_ Queue m si sm so a
q =
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (forall a b. a -> b -> a
const ()) (forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m a
enqueueStored Queue m si sm so a
q)
dequeueCount :: MonadDES m => Queue m si sm so a -> Event m Int
{-# INLINABLE dequeueCount #-}
dequeueCount :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m Int
dequeueCount Queue m si sm so a
q =
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event forall a b. (a -> b) -> a -> b
$ \Point m
p -> forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (forall (m :: * -> *) si sm so a. Queue m si sm so a -> Ref m Int
dequeueCountRef Queue m si sm so a
q)
dequeueCountChanged :: MonadDES m => Queue m si sm so a -> Signal m Int
{-# INLINABLE dequeueCountChanged #-}
dequeueCountChanged :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m Int
dequeueCountChanged Queue m si sm so a
q =
forall (m :: * -> *) a b.
MonadDES m =>
(a -> Event m b) -> Signal m a -> Signal m b
mapSignalM (forall a b. a -> b -> a
const forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m Int
dequeueCount Queue m si sm so a
q) (forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m ()
dequeueCountChanged_ Queue m si sm so a
q)
dequeueCountChanged_ :: MonadDES m => Queue m si sm so a -> Signal m ()
{-# INLINABLE dequeueCountChanged_ #-}
dequeueCountChanged_ :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m ()
dequeueCountChanged_ Queue m si sm so a
q =
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (forall a b. a -> b -> a
const ()) (forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m ()
dequeueRequested Queue m si sm so a
q)
dequeueExtractCount :: MonadDES m => Queue m si sm so a -> Event m Int
{-# INLINABLE dequeueExtractCount #-}
Queue m si sm so a
q =
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event forall a b. (a -> b) -> a -> b
$ \Point m
p -> forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (forall (m :: * -> *) si sm so a. Queue m si sm so a -> Ref m Int
dequeueExtractCountRef Queue m si sm so a
q)
dequeueExtractCountChanged :: MonadDES m => Queue m si sm so a -> Signal m Int
{-# INLINABLE dequeueExtractCountChanged #-}
Queue m si sm so a
q =
forall (m :: * -> *) a b.
MonadDES m =>
(a -> Event m b) -> Signal m a -> Signal m b
mapSignalM (forall a b. a -> b -> a
const forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m Int
dequeueExtractCount Queue m si sm so a
q) (forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m ()
dequeueExtractCountChanged_ Queue m si sm so a
q)
dequeueExtractCountChanged_ :: MonadDES m => Queue m si sm so a -> Signal m ()
{-# INLINABLE dequeueExtractCountChanged_ #-}
Queue m si sm so a
q =
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (forall a b. a -> b -> a
const ()) (forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m a
dequeueExtracted Queue m si sm so a
q)
queueLoadFactor :: MonadDES m => Queue m si sm so a -> Event m Double
{-# INLINABLE queueLoadFactor #-}
queueLoadFactor :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m Double
queueLoadFactor Queue m si sm so a
q =
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event forall a b. (a -> b) -> a -> b
$ \Point m
p ->
do Int
x <- forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (forall (m :: * -> *) si sm so a. Queue m si sm so a -> Ref m Int
queueCountRef Queue m si sm so a
q)
let y :: Int
y = forall (m :: * -> *) si sm so a. Queue m si sm so a -> Int
queueMaxCount Queue m si sm so a
q
forall (m :: * -> *) a. Monad m => a -> m a
return (forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
x forall a. Fractional a => a -> a -> a
/ forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
y)
queueLoadFactorChanged :: MonadDES m => Queue m si sm so a -> Signal m Double
{-# INLINABLE queueLoadFactorChanged #-}
queueLoadFactorChanged :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m Double
queueLoadFactorChanged Queue m si sm so a
q =
forall (m :: * -> *) a b.
MonadDES m =>
(a -> Event m b) -> Signal m a -> Signal m b
mapSignalM (forall a b. a -> b -> a
const forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m Double
queueLoadFactor Queue m si sm so a
q) (forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m ()
queueLoadFactorChanged_ Queue m si sm so a
q)
queueLoadFactorChanged_ :: MonadDES m => Queue m si sm so a -> Signal m ()
{-# INLINABLE queueLoadFactorChanged_ #-}
queueLoadFactorChanged_ :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m ()
queueLoadFactorChanged_ Queue m si sm so a
q =
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (forall a b. a -> b -> a
const ()) (forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m a
enqueueStored Queue m si sm so a
q) forall a. Semigroup a => a -> a -> a
<>
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (forall a b. a -> b -> a
const ()) (forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m a
dequeueExtracted Queue m si sm so a
q)
enqueueRate :: MonadDES m => Queue m si sm so a -> Event m Double
{-# INLINABLE enqueueRate #-}
enqueueRate :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m Double
enqueueRate Queue m si sm so a
q =
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event forall a b. (a -> b) -> a -> b
$ \Point m
p ->
do Int
x <- forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (forall (m :: * -> *) si sm so a. Queue m si sm so a -> Ref m Int
enqueueCountRef Queue m si sm so a
q)
let t0 :: Double
t0 = forall (m :: * -> *). Specs m -> Double
spcStartTime forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *). Point m -> Specs m
pointSpecs Point m
p
t :: Double
t = forall (m :: * -> *). Point m -> Double
pointTime Point m
p
forall (m :: * -> *) a. Monad m => a -> m a
return (forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
x forall a. Fractional a => a -> a -> a
/ (Double
t forall a. Num a => a -> a -> a
- Double
t0))
enqueueStoreRate :: MonadDES m => Queue m si sm so a -> Event m Double
{-# INLINABLE enqueueStoreRate #-}
enqueueStoreRate :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m Double
enqueueStoreRate Queue m si sm so a
q =
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event forall a b. (a -> b) -> a -> b
$ \Point m
p ->
do Int
x <- forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (forall (m :: * -> *) si sm so a. Queue m si sm so a -> Ref m Int
enqueueStoreCountRef Queue m si sm so a
q)
let t0 :: Double
t0 = forall (m :: * -> *). Specs m -> Double
spcStartTime forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *). Point m -> Specs m
pointSpecs Point m
p
t :: Double
t = forall (m :: * -> *). Point m -> Double
pointTime Point m
p
forall (m :: * -> *) a. Monad m => a -> m a
return (forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
x forall a. Fractional a => a -> a -> a
/ (Double
t forall a. Num a => a -> a -> a
- Double
t0))
dequeueRate :: MonadDES m => Queue m si sm so a -> Event m Double
{-# INLINABLE dequeueRate #-}
dequeueRate :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m Double
dequeueRate Queue m si sm so a
q =
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event forall a b. (a -> b) -> a -> b
$ \Point m
p ->
do Int
x <- forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (forall (m :: * -> *) si sm so a. Queue m si sm so a -> Ref m Int
dequeueCountRef Queue m si sm so a
q)
let t0 :: Double
t0 = forall (m :: * -> *). Specs m -> Double
spcStartTime forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *). Point m -> Specs m
pointSpecs Point m
p
t :: Double
t = forall (m :: * -> *). Point m -> Double
pointTime Point m
p
forall (m :: * -> *) a. Monad m => a -> m a
return (forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
x forall a. Fractional a => a -> a -> a
/ (Double
t forall a. Num a => a -> a -> a
- Double
t0))
dequeueExtractRate :: MonadDES m => Queue m si sm so a -> Event m Double
{-# INLINABLE dequeueExtractRate #-}
Queue m si sm so a
q =
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event forall a b. (a -> b) -> a -> b
$ \Point m
p ->
do Int
x <- forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (forall (m :: * -> *) si sm so a. Queue m si sm so a -> Ref m Int
dequeueExtractCountRef Queue m si sm so a
q)
let t0 :: Double
t0 = forall (m :: * -> *). Specs m -> Double
spcStartTime forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *). Point m -> Specs m
pointSpecs Point m
p
t :: Double
t = forall (m :: * -> *). Point m -> Double
pointTime Point m
p
forall (m :: * -> *) a. Monad m => a -> m a
return (forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
x forall a. Fractional a => a -> a -> a
/ (Double
t forall a. Num a => a -> a -> a
- Double
t0))
queueWaitTime :: MonadDES m => Queue m si sm so a -> Event m (SamplingStats Double)
{-# INLINABLE queueWaitTime #-}
queueWaitTime :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m (SamplingStats Double)
queueWaitTime Queue m si sm so a
q =
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event forall a b. (a -> b) -> a -> b
$ \Point m
p -> forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> Ref m (SamplingStats Double)
queueWaitTimeRef Queue m si sm so a
q)
queueWaitTimeChanged :: MonadDES m => Queue m si sm so a -> Signal m (SamplingStats Double)
{-# INLINABLE queueWaitTimeChanged #-}
queueWaitTimeChanged :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m (SamplingStats Double)
queueWaitTimeChanged Queue m si sm so a
q =
forall (m :: * -> *) a b.
MonadDES m =>
(a -> Event m b) -> Signal m a -> Signal m b
mapSignalM (forall a b. a -> b -> a
const forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m (SamplingStats Double)
queueWaitTime Queue m si sm so a
q) (forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m ()
queueWaitTimeChanged_ Queue m si sm so a
q)
queueWaitTimeChanged_ :: MonadDES m => Queue m si sm so a -> Signal m ()
{-# INLINABLE queueWaitTimeChanged_ #-}
queueWaitTimeChanged_ :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m ()
queueWaitTimeChanged_ Queue m si sm so a
q =
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (forall a b. a -> b -> a
const ()) (forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m a
dequeueExtracted Queue m si sm so a
q)
queueTotalWaitTime :: MonadDES m => Queue m si sm so a -> Event m (SamplingStats Double)
{-# INLINABLE queueTotalWaitTime #-}
queueTotalWaitTime :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m (SamplingStats Double)
queueTotalWaitTime Queue m si sm so a
q =
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event forall a b. (a -> b) -> a -> b
$ \Point m
p -> forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> Ref m (SamplingStats Double)
queueTotalWaitTimeRef Queue m si sm so a
q)
queueTotalWaitTimeChanged :: MonadDES m => Queue m si sm so a -> Signal m (SamplingStats Double)
{-# INLINABLE queueTotalWaitTimeChanged #-}
queueTotalWaitTimeChanged :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m (SamplingStats Double)
queueTotalWaitTimeChanged Queue m si sm so a
q =
forall (m :: * -> *) a b.
MonadDES m =>
(a -> Event m b) -> Signal m a -> Signal m b
mapSignalM (forall a b. a -> b -> a
const forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m (SamplingStats Double)
queueTotalWaitTime Queue m si sm so a
q) (forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m ()
queueTotalWaitTimeChanged_ Queue m si sm so a
q)
queueTotalWaitTimeChanged_ :: MonadDES m => Queue m si sm so a -> Signal m ()
{-# INLINABLE queueTotalWaitTimeChanged_ #-}
queueTotalWaitTimeChanged_ :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m ()
queueTotalWaitTimeChanged_ Queue m si sm so a
q =
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (forall a b. a -> b -> a
const ()) (forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m a
dequeueExtracted Queue m si sm so a
q)
enqueueWaitTime :: MonadDES m => Queue m si sm so a -> Event m (SamplingStats Double)
{-# INLINABLE enqueueWaitTime #-}
enqueueWaitTime :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m (SamplingStats Double)
enqueueWaitTime Queue m si sm so a
q =
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event forall a b. (a -> b) -> a -> b
$ \Point m
p -> forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> Ref m (SamplingStats Double)
enqueueWaitTimeRef Queue m si sm so a
q)
enqueueWaitTimeChanged :: MonadDES m => Queue m si sm so a -> Signal m (SamplingStats Double)
{-# INLINABLE enqueueWaitTimeChanged #-}
enqueueWaitTimeChanged :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m (SamplingStats Double)
enqueueWaitTimeChanged Queue m si sm so a
q =
forall (m :: * -> *) a b.
MonadDES m =>
(a -> Event m b) -> Signal m a -> Signal m b
mapSignalM (forall a b. a -> b -> a
const forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m (SamplingStats Double)
enqueueWaitTime Queue m si sm so a
q) (forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m ()
enqueueWaitTimeChanged_ Queue m si sm so a
q)
enqueueWaitTimeChanged_ :: MonadDES m => Queue m si sm so a -> Signal m ()
{-# INLINABLE enqueueWaitTimeChanged_ #-}
enqueueWaitTimeChanged_ :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m ()
enqueueWaitTimeChanged_ Queue m si sm so a
q =
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (forall a b. a -> b -> a
const ()) (forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m a
enqueueStored Queue m si sm so a
q)
dequeueWaitTime :: MonadDES m => Queue m si sm so a -> Event m (SamplingStats Double)
{-# INLINABLE dequeueWaitTime #-}
dequeueWaitTime :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m (SamplingStats Double)
dequeueWaitTime Queue m si sm so a
q =
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event forall a b. (a -> b) -> a -> b
$ \Point m
p -> forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> Ref m (SamplingStats Double)
dequeueWaitTimeRef Queue m si sm so a
q)
dequeueWaitTimeChanged :: MonadDES m => Queue m si sm so a -> Signal m (SamplingStats Double)
{-# INLINABLE dequeueWaitTimeChanged #-}
dequeueWaitTimeChanged :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m (SamplingStats Double)
dequeueWaitTimeChanged Queue m si sm so a
q =
forall (m :: * -> *) a b.
MonadDES m =>
(a -> Event m b) -> Signal m a -> Signal m b
mapSignalM (forall a b. a -> b -> a
const forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m (SamplingStats Double)
dequeueWaitTime Queue m si sm so a
q) (forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m ()
dequeueWaitTimeChanged_ Queue m si sm so a
q)
dequeueWaitTimeChanged_ :: MonadDES m => Queue m si sm so a -> Signal m ()
{-# INLINABLE dequeueWaitTimeChanged_ #-}
dequeueWaitTimeChanged_ :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m ()
dequeueWaitTimeChanged_ Queue m si sm so a
q =
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (forall a b. a -> b -> a
const ()) (forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m a
dequeueExtracted Queue m si sm so a
q)
queueRate :: MonadDES m => Queue m si sm so a -> Event m Double
{-# INLINABLE queueRate #-}
queueRate :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m Double
queueRate Queue m si sm so a
q =
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event forall a b. (a -> b) -> a -> b
$ \Point m
p ->
do TimingStats Int
x <- forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> Ref m (TimingStats Int)
queueCountStatsRef Queue m si sm so a
q)
SamplingStats Double
y <- forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> Ref m (SamplingStats Double)
queueWaitTimeRef Queue m si sm so a
q)
forall (m :: * -> *) a. Monad m => a -> m a
return (forall a. TimingData a => TimingStats a -> Double
timingStatsMean TimingStats Int
x forall a. Fractional a => a -> a -> a
/ forall a. SamplingStats a -> Double
samplingStatsMean SamplingStats Double
y)
queueRateChanged :: MonadDES m => Queue m si sm so a -> Signal m Double
{-# INLINABLE queueRateChanged #-}
queueRateChanged :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m Double
queueRateChanged Queue m si sm so a
q =
forall (m :: * -> *) a b.
MonadDES m =>
(a -> Event m b) -> Signal m a -> Signal m b
mapSignalM (forall a b. a -> b -> a
const forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m Double
queueRate Queue m si sm so a
q) (forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m ()
queueRateChanged_ Queue m si sm so a
q)
queueRateChanged_ :: MonadDES m => Queue m si sm so a -> Signal m ()
{-# INLINABLE queueRateChanged_ #-}
queueRateChanged_ :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m ()
queueRateChanged_ Queue m si sm so a
q =
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (forall a b. a -> b -> a
const ()) (forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m a
enqueueStored Queue m si sm so a
q) forall a. Semigroup a => a -> a -> a
<>
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (forall a b. a -> b -> a
const ()) (forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m a
dequeueExtracted Queue m si sm so a
q)
dequeue :: (MonadDES m,
DequeueStrategy m si,
DequeueStrategy m sm,
EnqueueStrategy m so)
=> Queue m si sm so a
-> Process m a
{-# INLINABLE dequeue #-}
dequeue :: forall (m :: * -> *) si sm so a.
(MonadDES m, DequeueStrategy m si, DequeueStrategy m sm,
EnqueueStrategy m so) =>
Queue m si sm so a -> Process m a
dequeue Queue m si sm so a
q =
do Double
t <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
EventLift t m =>
Event m a -> t m a
liftEvent forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m Double
dequeueRequest Queue m si sm so a
q
forall (m :: * -> *) s.
(MonadDES m, EnqueueStrategy m s) =>
Resource m s -> Process m ()
requestResource (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> Resource m so
dequeueRes Queue m si sm so a
q)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
EventLift t m =>
Event m a -> t m a
liftEvent forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) si sm so a.
(MonadDES m, DequeueStrategy m si, DequeueStrategy m sm) =>
Queue m si sm so a -> Double -> Event m a
dequeueExtract Queue m si sm so a
q Double
t
dequeueWithOutputPriority :: (MonadDES m,
DequeueStrategy m si,
DequeueStrategy m sm,
PriorityQueueStrategy m so po)
=> Queue m si sm so a
-> po
-> Process m a
{-# INLINABLE dequeueWithOutputPriority #-}
dequeueWithOutputPriority :: forall (m :: * -> *) si sm so po a.
(MonadDES m, DequeueStrategy m si, DequeueStrategy m sm,
PriorityQueueStrategy m so po) =>
Queue m si sm so a -> po -> Process m a
dequeueWithOutputPriority Queue m si sm so a
q po
po =
do Double
t <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
EventLift t m =>
Event m a -> t m a
liftEvent forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m Double
dequeueRequest Queue m si sm so a
q
forall (m :: * -> *) s p.
(MonadDES m, PriorityQueueStrategy m s p) =>
Resource m s -> p -> Process m ()
requestResourceWithPriority (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> Resource m so
dequeueRes Queue m si sm so a
q) po
po
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
EventLift t m =>
Event m a -> t m a
liftEvent forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) si sm so a.
(MonadDES m, DequeueStrategy m si, DequeueStrategy m sm) =>
Queue m si sm so a -> Double -> Event m a
dequeueExtract Queue m si sm so a
q Double
t
tryDequeue :: (MonadDES m,
DequeueStrategy m si,
DequeueStrategy m sm)
=> Queue m si sm so a
-> Event m (Maybe a)
{-# INLINABLE tryDequeue #-}
tryDequeue :: forall (m :: * -> *) si sm so a.
(MonadDES m, DequeueStrategy m si, DequeueStrategy m sm) =>
Queue m si sm so a -> Event m (Maybe a)
tryDequeue Queue m si sm so a
q =
do Bool
x <- forall (m :: * -> *) s. MonadDES m => Resource m s -> Event m Bool
tryRequestResourceWithinEvent (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> Resource m so
dequeueRes Queue m si sm so a
q)
if Bool
x
then do Double
t <- forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m Double
dequeueRequest Queue m si sm so a
q
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) si sm so a.
(MonadDES m, DequeueStrategy m si, DequeueStrategy m sm) =>
Queue m si sm so a -> Double -> Event m a
dequeueExtract Queue m si sm so a
q Double
t
else forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Maybe a
Nothing
queueDelete :: (MonadDES m,
Eq a,
DequeueStrategy m si,
DeletingQueueStrategy m sm,
DequeueStrategy m so)
=> Queue m si sm so a
-> a
-> Event m Bool
{-# INLINABLE queueDelete #-}
queueDelete :: forall (m :: * -> *) a si sm so.
(MonadDES m, Eq a, DequeueStrategy m si,
DeletingQueueStrategy m sm, DequeueStrategy m so) =>
Queue m si sm so a -> a -> Event m Bool
queueDelete Queue m si sm so a
q a
a = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Maybe a -> Bool
isJust forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) si sm so a.
(MonadDES m, DequeueStrategy m si, DeletingQueueStrategy m sm,
DequeueStrategy m so) =>
Queue m si sm so a -> (a -> Bool) -> Event m (Maybe a)
queueDeleteBy Queue m si sm so a
q (forall a. Eq a => a -> a -> Bool
== a
a)
queueDelete_ :: (MonadDES m,
Eq a,
DequeueStrategy m si,
DeletingQueueStrategy m sm,
DequeueStrategy m so)
=> Queue m si sm so a
-> a
-> Event m ()
{-# INLINABLE queueDelete_ #-}
queueDelete_ :: forall (m :: * -> *) a si sm so.
(MonadDES m, Eq a, DequeueStrategy m si,
DeletingQueueStrategy m sm, DequeueStrategy m so) =>
Queue m si sm so a -> a -> Event m ()
queueDelete_ Queue m si sm so a
q a
a = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall a b. a -> b -> a
const ()) forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) si sm so a.
(MonadDES m, DequeueStrategy m si, DeletingQueueStrategy m sm,
DequeueStrategy m so) =>
Queue m si sm so a -> (a -> Bool) -> Event m (Maybe a)
queueDeleteBy Queue m si sm so a
q (forall a. Eq a => a -> a -> Bool
== a
a)
queueDeleteBy :: (MonadDES m,
DequeueStrategy m si,
DeletingQueueStrategy m sm,
DequeueStrategy m so)
=> Queue m si sm so a
-> (a -> Bool)
-> Event m (Maybe a)
{-# INLINABLE queueDeleteBy #-}
queueDeleteBy :: forall (m :: * -> *) si sm so a.
(MonadDES m, DequeueStrategy m si, DeletingQueueStrategy m sm,
DequeueStrategy m so) =>
Queue m si sm so a -> (a -> Bool) -> Event m (Maybe a)
queueDeleteBy Queue m si sm so a
q a -> Bool
pred =
do Bool
x <- forall (m :: * -> *) s. MonadDES m => Resource m s -> Event m Bool
tryRequestResourceWithinEvent (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> Resource m so
dequeueRes Queue m si sm so a
q)
if Bool
x
then do Maybe (QueueItem a)
i <- forall (m :: * -> *) s a.
DeletingQueueStrategy m s =>
StrategyQueue m s a -> (a -> Bool) -> Event m (Maybe a)
strategyQueueDeleteBy (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> StrategyQueue m sm (QueueItem a)
queueStore Queue m si sm so a
q) (a -> Bool
pred forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. QueueItem a -> a
itemValue)
case Maybe (QueueItem a)
i of
Maybe (QueueItem a)
Nothing ->
do forall (m :: * -> *) s.
(MonadDES m, DequeueStrategy m s) =>
Resource m s -> Event m ()
releaseResourceWithinEvent (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> Resource m so
dequeueRes Queue m si sm so a
q)
forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Maybe a
Nothing
Just QueueItem a
i ->
do Double
t <- forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m Double
dequeueRequest Queue m si sm so a
q
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) si sm so a.
(MonadDES m, DequeueStrategy m si, DequeueStrategy m sm) =>
Queue m si sm so a -> Double -> QueueItem a -> Event m a
dequeuePostExtract Queue m si sm so a
q Double
t QueueItem a
i
else forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Maybe a
Nothing
queueDeleteBy_ :: (MonadDES m,
DequeueStrategy m si,
DeletingQueueStrategy m sm,
DequeueStrategy m so)
=> Queue m si sm so a
-> (a -> Bool)
-> Event m ()
{-# INLINABLE queueDeleteBy_ #-}
queueDeleteBy_ :: forall (m :: * -> *) si sm so a.
(MonadDES m, DequeueStrategy m si, DeletingQueueStrategy m sm,
DequeueStrategy m so) =>
Queue m si sm so a -> (a -> Bool) -> Event m ()
queueDeleteBy_ Queue m si sm so a
q a -> Bool
pred = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall a b. a -> b -> a
const ()) forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) si sm so a.
(MonadDES m, DequeueStrategy m si, DeletingQueueStrategy m sm,
DequeueStrategy m so) =>
Queue m si sm so a -> (a -> Bool) -> Event m (Maybe a)
queueDeleteBy Queue m si sm so a
q a -> Bool
pred
queueContains :: (MonadDES m,
Eq a,
DeletingQueueStrategy m sm)
=> Queue m si sm so a
-> a
-> Event m Bool
{-# INLINABLE queueContains #-}
queueContains :: forall (m :: * -> *) a sm si so.
(MonadDES m, Eq a, DeletingQueueStrategy m sm) =>
Queue m si sm so a -> a -> Event m Bool
queueContains Queue m si sm so a
q a
a = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Maybe a -> Bool
isJust forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) sm si so a.
(MonadDES m, DeletingQueueStrategy m sm) =>
Queue m si sm so a -> (a -> Bool) -> Event m (Maybe a)
queueContainsBy Queue m si sm so a
q (forall a. Eq a => a -> a -> Bool
== a
a)
queueContainsBy :: (MonadDES m,
DeletingQueueStrategy m sm)
=> Queue m si sm so a
-> (a -> Bool)
-> Event m (Maybe a)
{-# INLINABLE queueContainsBy #-}
queueContainsBy :: forall (m :: * -> *) sm si so a.
(MonadDES m, DeletingQueueStrategy m sm) =>
Queue m si sm so a -> (a -> Bool) -> Event m (Maybe a)
queueContainsBy Queue m si sm so a
q a -> Bool
pred =
do Maybe (QueueItem a)
x <- forall (m :: * -> *) s a.
DeletingQueueStrategy m s =>
StrategyQueue m s a -> (a -> Bool) -> Event m (Maybe a)
strategyQueueContainsBy (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> StrategyQueue m sm (QueueItem a)
queueStore Queue m si sm so a
q) (a -> Bool
pred forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. QueueItem a -> a
itemValue)
case Maybe (QueueItem a)
x of
Maybe (QueueItem a)
Nothing -> forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Maybe a
Nothing
Just QueueItem a
i -> forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall a. a -> Maybe a
Just (forall a. QueueItem a -> a
itemValue QueueItem a
i)
clearQueue :: (MonadDES m,
DequeueStrategy m si,
DequeueStrategy m sm)
=> Queue m si sm so a
-> Event m ()
{-# INLINABLE clearQueue #-}
clearQueue :: forall (m :: * -> *) si sm so a.
(MonadDES m, DequeueStrategy m si, DequeueStrategy m sm) =>
Queue m si sm so a -> Event m ()
clearQueue Queue m si sm so a
q =
do Maybe a
x <- forall (m :: * -> *) si sm so a.
(MonadDES m, DequeueStrategy m si, DequeueStrategy m sm) =>
Queue m si sm so a -> Event m (Maybe a)
tryDequeue Queue m si sm so a
q
case Maybe a
x of
Maybe a
Nothing -> forall (m :: * -> *) a. Monad m => a -> m a
return ()
Just a
a -> forall (m :: * -> *) si sm so a.
(MonadDES m, DequeueStrategy m si, DequeueStrategy m sm) =>
Queue m si sm so a -> Event m ()
clearQueue Queue m si sm so a
q
enqueue :: (MonadDES m,
EnqueueStrategy m si,
EnqueueStrategy m sm,
DequeueStrategy m so)
=> Queue m si sm so a
-> a
-> Process m ()
{-# INLINABLE enqueue #-}
enqueue :: forall (m :: * -> *) si sm so a.
(MonadDES m, EnqueueStrategy m si, EnqueueStrategy m sm,
DequeueStrategy m so) =>
Queue m si sm so a -> a -> Process m ()
enqueue Queue m si sm so a
q a
a =
do QueueItem a
i <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
EventLift t m =>
Event m a -> t m a
liftEvent forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> a -> Event m (QueueItem a)
enqueueInitiate Queue m si sm so a
q a
a
forall (m :: * -> *) s.
(MonadDES m, EnqueueStrategy m s) =>
Resource m s -> Process m ()
requestResource (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> Resource m si
enqueueRes Queue m si sm so a
q)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
EventLift t m =>
Event m a -> t m a
liftEvent forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) sm so si a.
(MonadDES m, EnqueueStrategy m sm, DequeueStrategy m so) =>
Queue m si sm so a -> QueueItem a -> Event m ()
enqueueStore Queue m si sm so a
q QueueItem a
i
enqueueWithInputPriority :: (MonadDES m,
PriorityQueueStrategy m si pi,
EnqueueStrategy m sm,
DequeueStrategy m so)
=> Queue m si sm so a
-> pi
-> a
-> Process m ()
{-# INLINABLE enqueueWithInputPriority #-}
enqueueWithInputPriority :: forall (m :: * -> *) si pi sm so a.
(MonadDES m, PriorityQueueStrategy m si pi, EnqueueStrategy m sm,
DequeueStrategy m so) =>
Queue m si sm so a -> pi -> a -> Process m ()
enqueueWithInputPriority Queue m si sm so a
q pi
pi a
a =
do QueueItem a
i <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
EventLift t m =>
Event m a -> t m a
liftEvent forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> a -> Event m (QueueItem a)
enqueueInitiate Queue m si sm so a
q a
a
forall (m :: * -> *) s p.
(MonadDES m, PriorityQueueStrategy m s p) =>
Resource m s -> p -> Process m ()
requestResourceWithPriority (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> Resource m si
enqueueRes Queue m si sm so a
q) pi
pi
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
EventLift t m =>
Event m a -> t m a
liftEvent forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) sm so si a.
(MonadDES m, EnqueueStrategy m sm, DequeueStrategy m so) =>
Queue m si sm so a -> QueueItem a -> Event m ()
enqueueStore Queue m si sm so a
q QueueItem a
i
enqueueWithStoringPriority :: (MonadDES m,
EnqueueStrategy m si,
PriorityQueueStrategy m sm pm,
DequeueStrategy m so)
=> Queue m si sm so a
-> pm
-> a
-> Process m ()
{-# INLINABLE enqueueWithStoringPriority #-}
enqueueWithStoringPriority :: forall (m :: * -> *) si sm pm so a.
(MonadDES m, EnqueueStrategy m si, PriorityQueueStrategy m sm pm,
DequeueStrategy m so) =>
Queue m si sm so a -> pm -> a -> Process m ()
enqueueWithStoringPriority Queue m si sm so a
q pm
pm a
a =
do QueueItem a
i <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
EventLift t m =>
Event m a -> t m a
liftEvent forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> a -> Event m (QueueItem a)
enqueueInitiate Queue m si sm so a
q a
a
forall (m :: * -> *) s.
(MonadDES m, EnqueueStrategy m s) =>
Resource m s -> Process m ()
requestResource (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> Resource m si
enqueueRes Queue m si sm so a
q)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
EventLift t m =>
Event m a -> t m a
liftEvent forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) sm pm so si a.
(MonadDES m, PriorityQueueStrategy m sm pm,
DequeueStrategy m so) =>
Queue m si sm so a -> pm -> QueueItem a -> Event m ()
enqueueStoreWithPriority Queue m si sm so a
q pm
pm QueueItem a
i
enqueueWithInputStoringPriorities :: (MonadDES m,
PriorityQueueStrategy m si pi,
PriorityQueueStrategy m sm pm,
DequeueStrategy m so)
=> Queue m si sm so a
-> pi
-> pm
-> a
-> Process m ()
{-# INLINABLE enqueueWithInputStoringPriorities #-}
enqueueWithInputStoringPriorities :: forall (m :: * -> *) si pi sm pm so a.
(MonadDES m, PriorityQueueStrategy m si pi,
PriorityQueueStrategy m sm pm, DequeueStrategy m so) =>
Queue m si sm so a -> pi -> pm -> a -> Process m ()
enqueueWithInputStoringPriorities Queue m si sm so a
q pi
pi pm
pm a
a =
do QueueItem a
i <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
EventLift t m =>
Event m a -> t m a
liftEvent forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> a -> Event m (QueueItem a)
enqueueInitiate Queue m si sm so a
q a
a
forall (m :: * -> *) s p.
(MonadDES m, PriorityQueueStrategy m s p) =>
Resource m s -> p -> Process m ()
requestResourceWithPriority (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> Resource m si
enqueueRes Queue m si sm so a
q) pi
pi
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
EventLift t m =>
Event m a -> t m a
liftEvent forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) sm pm so si a.
(MonadDES m, PriorityQueueStrategy m sm pm,
DequeueStrategy m so) =>
Queue m si sm so a -> pm -> QueueItem a -> Event m ()
enqueueStoreWithPriority Queue m si sm so a
q pm
pm QueueItem a
i
tryEnqueue :: (MonadDES m,
EnqueueStrategy m sm,
DequeueStrategy m so)
=> Queue m si sm so a
-> a
-> Event m Bool
{-# INLINABLE tryEnqueue #-}
tryEnqueue :: forall (m :: * -> *) sm so si a.
(MonadDES m, EnqueueStrategy m sm, DequeueStrategy m so) =>
Queue m si sm so a -> a -> Event m Bool
tryEnqueue Queue m si sm so a
q a
a =
do Bool
x <- forall (m :: * -> *) s. MonadDES m => Resource m s -> Event m Bool
tryRequestResourceWithinEvent (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> Resource m si
enqueueRes Queue m si sm so a
q)
if Bool
x
then do forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> a -> Event m (QueueItem a)
enqueueInitiate Queue m si sm so a
q a
a forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall (m :: * -> *) sm so si a.
(MonadDES m, EnqueueStrategy m sm, DequeueStrategy m so) =>
Queue m si sm so a -> QueueItem a -> Event m ()
enqueueStore Queue m si sm so a
q
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
True
else forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False
tryEnqueueWithStoringPriority :: (MonadDES m,
PriorityQueueStrategy m sm pm,
DequeueStrategy m so)
=> Queue m si sm so a
-> pm
-> a
-> Event m Bool
{-# INLINABLE tryEnqueueWithStoringPriority #-}
tryEnqueueWithStoringPriority :: forall (m :: * -> *) sm pm so si a.
(MonadDES m, PriorityQueueStrategy m sm pm,
DequeueStrategy m so) =>
Queue m si sm so a -> pm -> a -> Event m Bool
tryEnqueueWithStoringPriority Queue m si sm so a
q pm
pm a
a =
do Bool
x <- forall (m :: * -> *) s. MonadDES m => Resource m s -> Event m Bool
tryRequestResourceWithinEvent (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> Resource m si
enqueueRes Queue m si sm so a
q)
if Bool
x
then do forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> a -> Event m (QueueItem a)
enqueueInitiate Queue m si sm so a
q a
a forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall (m :: * -> *) sm pm so si a.
(MonadDES m, PriorityQueueStrategy m sm pm,
DequeueStrategy m so) =>
Queue m si sm so a -> pm -> QueueItem a -> Event m ()
enqueueStoreWithPriority Queue m si sm so a
q pm
pm
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
True
else forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False
enqueueOrLost :: (MonadDES m,
EnqueueStrategy m sm,
DequeueStrategy m so)
=> Queue m si sm so a
-> a
-> Event m Bool
{-# INLINABLE enqueueOrLost #-}
enqueueOrLost :: forall (m :: * -> *) sm so si a.
(MonadDES m, EnqueueStrategy m sm, DequeueStrategy m so) =>
Queue m si sm so a -> a -> Event m Bool
enqueueOrLost Queue m si sm so a
q a
a =
do Bool
x <- forall (m :: * -> *) s. MonadDES m => Resource m s -> Event m Bool
tryRequestResourceWithinEvent (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> Resource m si
enqueueRes Queue m si sm so a
q)
if Bool
x
then do forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> a -> Event m (QueueItem a)
enqueueInitiate Queue m si sm so a
q a
a forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall (m :: * -> *) sm so si a.
(MonadDES m, EnqueueStrategy m sm, DequeueStrategy m so) =>
Queue m si sm so a -> QueueItem a -> Event m ()
enqueueStore Queue m si sm so a
q
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
True
else do forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> a -> Event m ()
enqueueDeny Queue m si sm so a
q a
a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False
enqueueWithStoringPriorityOrLost :: (MonadDES m,
PriorityQueueStrategy m sm pm,
DequeueStrategy m so)
=> Queue m si sm so a
-> pm
-> a
-> Event m Bool
{-# INLINABLE enqueueWithStoringPriorityOrLost #-}
enqueueWithStoringPriorityOrLost :: forall (m :: * -> *) sm pm so si a.
(MonadDES m, PriorityQueueStrategy m sm pm,
DequeueStrategy m so) =>
Queue m si sm so a -> pm -> a -> Event m Bool
enqueueWithStoringPriorityOrLost Queue m si sm so a
q pm
pm a
a =
do Bool
x <- forall (m :: * -> *) s. MonadDES m => Resource m s -> Event m Bool
tryRequestResourceWithinEvent (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> Resource m si
enqueueRes Queue m si sm so a
q)
if Bool
x
then do forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> a -> Event m (QueueItem a)
enqueueInitiate Queue m si sm so a
q a
a forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall (m :: * -> *) sm pm so si a.
(MonadDES m, PriorityQueueStrategy m sm pm,
DequeueStrategy m so) =>
Queue m si sm so a -> pm -> QueueItem a -> Event m ()
enqueueStoreWithPriority Queue m si sm so a
q pm
pm
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
True
else do forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> a -> Event m ()
enqueueDeny Queue m si sm so a
q a
a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False
enqueueOrLost_ :: (MonadDES m,
EnqueueStrategy m sm,
DequeueStrategy m so)
=> Queue m si sm so a
-> a
-> Event m ()
{-# INLINABLE enqueueOrLost_ #-}
enqueueOrLost_ :: forall (m :: * -> *) sm so si a.
(MonadDES m, EnqueueStrategy m sm, DequeueStrategy m so) =>
Queue m si sm so a -> a -> Event m ()
enqueueOrLost_ Queue m si sm so a
q a
a =
do Bool
x <- forall (m :: * -> *) sm so si a.
(MonadDES m, EnqueueStrategy m sm, DequeueStrategy m so) =>
Queue m si sm so a -> a -> Event m Bool
enqueueOrLost Queue m si sm so a
q a
a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
enqueueWithStoringPriorityOrLost_ :: (MonadDES m,
PriorityQueueStrategy m sm pm,
DequeueStrategy m so)
=> Queue m si sm so a
-> pm
-> a
-> Event m ()
{-# INLINABLE enqueueWithStoringPriorityOrLost_ #-}
enqueueWithStoringPriorityOrLost_ :: forall (m :: * -> *) sm pm so si a.
(MonadDES m, PriorityQueueStrategy m sm pm,
DequeueStrategy m so) =>
Queue m si sm so a -> pm -> a -> Event m ()
enqueueWithStoringPriorityOrLost_ Queue m si sm so a
q pm
pm a
a =
do Bool
x <- forall (m :: * -> *) sm pm so si a.
(MonadDES m, PriorityQueueStrategy m sm pm,
DequeueStrategy m so) =>
Queue m si sm so a -> pm -> a -> Event m Bool
enqueueWithStoringPriorityOrLost Queue m si sm so a
q pm
pm a
a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
enqueueInitiated :: MonadDES m => Queue m si sm so a -> Signal m a
{-# INLINABLE enqueueInitiated #-}
enqueueInitiated :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m a
enqueueInitiated Queue m si sm so a
q = forall (m :: * -> *) a. SignalSource m a -> Signal m a
publishSignal (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> SignalSource m a
enqueueInitiatedSource Queue m si sm so a
q)
enqueueStored :: MonadDES m => Queue m si sm so a -> Signal m a
{-# INLINABLE enqueueStored #-}
enqueueStored :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m a
enqueueStored Queue m si sm so a
q = forall (m :: * -> *) a. SignalSource m a -> Signal m a
publishSignal (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> SignalSource m a
enqueueStoredSource Queue m si sm so a
q)
enqueueLost :: MonadDES m => Queue m si sm so a -> Signal m a
{-# INLINABLE enqueueLost #-}
enqueueLost :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m a
enqueueLost Queue m si sm so a
q = forall (m :: * -> *) a. SignalSource m a -> Signal m a
publishSignal (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> SignalSource m a
enqueueLostSource Queue m si sm so a
q)
dequeueRequested :: MonadDES m => Queue m si sm so a -> Signal m ()
{-# INLINABLE dequeueRequested #-}
dequeueRequested :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m ()
dequeueRequested Queue m si sm so a
q = forall (m :: * -> *) a. SignalSource m a -> Signal m a
publishSignal (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> SignalSource m ()
dequeueRequestedSource Queue m si sm so a
q)
dequeueExtracted :: MonadDES m => Queue m si sm so a -> Signal m a
{-# INLINABLE dequeueExtracted #-}
Queue m si sm so a
q = forall (m :: * -> *) a. SignalSource m a -> Signal m a
publishSignal (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> SignalSource m a
dequeueExtractedSource Queue m si sm so a
q)
enqueueInitiate :: MonadDES m
=> Queue m si sm so a
-> a
-> Event m (QueueItem a)
{-# INLINE enqueueInitiate #-}
enqueueInitiate :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> a -> Event m (QueueItem a)
enqueueInitiate Queue m si sm so a
q a
a =
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event forall a b. (a -> b) -> a -> b
$ \Point m
p ->
do let t :: Double
t = forall (m :: * -> *). Point m -> Double
pointTime Point m
p
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *) a.
MonadRef m =>
Ref m a -> (a -> a) -> Event m ()
modifyRef (forall (m :: * -> *) si sm so a. Queue m si sm so a -> Ref m Int
enqueueCountRef Queue m si sm so a
q) (forall a. Num a => a -> a -> a
+ Int
1)
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *) a. SignalSource m a -> a -> Event m ()
triggerSignal (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> SignalSource m a
enqueueInitiatedSource Queue m si sm so a
q) a
a
forall (m :: * -> *) a. Monad m => a -> m a
return QueueItem { itemValue :: a
itemValue = a
a,
itemInputTime :: Double
itemInputTime = Double
t,
itemStoringTime :: Double
itemStoringTime = Double
t
}
enqueueStore :: (MonadDES m,
EnqueueStrategy m sm,
DequeueStrategy m so)
=> Queue m si sm so a
-> QueueItem a
-> Event m ()
{-# INLINE enqueueStore #-}
enqueueStore :: forall (m :: * -> *) sm so si a.
(MonadDES m, EnqueueStrategy m sm, DequeueStrategy m so) =>
Queue m si sm so a -> QueueItem a -> Event m ()
enqueueStore Queue m si sm so a
q QueueItem a
i =
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event forall a b. (a -> b) -> a -> b
$ \Point m
p ->
do let i' :: QueueItem a
i' = QueueItem a
i { itemStoringTime :: Double
itemStoringTime = forall (m :: * -> *). Point m -> Double
pointTime Point m
p }
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *) s a.
EnqueueStrategy m s =>
StrategyQueue m s a -> a -> Event m ()
strategyEnqueue (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> StrategyQueue m sm (QueueItem a)
queueStore Queue m si sm so a
q) QueueItem a
i'
Int
c <- forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (forall (m :: * -> *) si sm so a. Queue m si sm so a -> Ref m Int
queueCountRef Queue m si sm so a
q)
let c' :: Int
c' = Int
c forall a. Num a => a -> a -> a
+ Int
1
t :: Double
t = forall (m :: * -> *). Point m -> Double
pointTime Point m
p
Int
c' seq :: forall a b. a -> b -> b
`seq` forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *) a. MonadRef m => Ref m a -> a -> Event m ()
writeRef (forall (m :: * -> *) si sm so a. Queue m si sm so a -> Ref m Int
queueCountRef Queue m si sm so a
q) Int
c'
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *) a.
MonadRef m =>
Ref m a -> (a -> a) -> Event m ()
modifyRef (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> Ref m (TimingStats Int)
queueCountStatsRef Queue m si sm so a
q) (forall a.
TimingData a =>
Double -> a -> TimingStats a -> TimingStats a
addTimingStats Double
t Int
c')
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *) a.
MonadRef m =>
Ref m a -> (a -> a) -> Event m ()
modifyRef (forall (m :: * -> *) si sm so a. Queue m si sm so a -> Ref m Int
enqueueStoreCountRef Queue m si sm so a
q) (forall a. Num a => a -> a -> a
+ Int
1)
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> QueueItem a -> Event m ()
enqueueStat Queue m si sm so a
q QueueItem a
i'
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *) s.
(MonadDES m, DequeueStrategy m s) =>
Resource m s -> Event m ()
releaseResourceWithinEvent (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> Resource m so
dequeueRes Queue m si sm so a
q)
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *) a. SignalSource m a -> a -> Event m ()
triggerSignal (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> SignalSource m a
enqueueStoredSource Queue m si sm so a
q) (forall a. QueueItem a -> a
itemValue QueueItem a
i')
enqueueStoreWithPriority :: (MonadDES m,
PriorityQueueStrategy m sm pm,
DequeueStrategy m so)
=> Queue m si sm so a
-> pm
-> QueueItem a
-> Event m ()
{-# INLINE enqueueStoreWithPriority #-}
enqueueStoreWithPriority :: forall (m :: * -> *) sm pm so si a.
(MonadDES m, PriorityQueueStrategy m sm pm,
DequeueStrategy m so) =>
Queue m si sm so a -> pm -> QueueItem a -> Event m ()
enqueueStoreWithPriority Queue m si sm so a
q pm
pm QueueItem a
i =
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event forall a b. (a -> b) -> a -> b
$ \Point m
p ->
do let i' :: QueueItem a
i' = QueueItem a
i { itemStoringTime :: Double
itemStoringTime = forall (m :: * -> *). Point m -> Double
pointTime Point m
p }
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *) s p a.
PriorityQueueStrategy m s p =>
StrategyQueue m s a -> p -> a -> Event m ()
strategyEnqueueWithPriority (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> StrategyQueue m sm (QueueItem a)
queueStore Queue m si sm so a
q) pm
pm QueueItem a
i'
Int
c <- forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (forall (m :: * -> *) si sm so a. Queue m si sm so a -> Ref m Int
queueCountRef Queue m si sm so a
q)
let c' :: Int
c' = Int
c forall a. Num a => a -> a -> a
+ Int
1
t :: Double
t = forall (m :: * -> *). Point m -> Double
pointTime Point m
p
Int
c' seq :: forall a b. a -> b -> b
`seq` forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *) a. MonadRef m => Ref m a -> a -> Event m ()
writeRef (forall (m :: * -> *) si sm so a. Queue m si sm so a -> Ref m Int
queueCountRef Queue m si sm so a
q) Int
c'
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *) a.
MonadRef m =>
Ref m a -> (a -> a) -> Event m ()
modifyRef (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> Ref m (TimingStats Int)
queueCountStatsRef Queue m si sm so a
q) (forall a.
TimingData a =>
Double -> a -> TimingStats a -> TimingStats a
addTimingStats Double
t Int
c')
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *) a.
MonadRef m =>
Ref m a -> (a -> a) -> Event m ()
modifyRef (forall (m :: * -> *) si sm so a. Queue m si sm so a -> Ref m Int
enqueueStoreCountRef Queue m si sm so a
q) (forall a. Num a => a -> a -> a
+ Int
1)
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> QueueItem a -> Event m ()
enqueueStat Queue m si sm so a
q QueueItem a
i'
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *) s.
(MonadDES m, DequeueStrategy m s) =>
Resource m s -> Event m ()
releaseResourceWithinEvent (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> Resource m so
dequeueRes Queue m si sm so a
q)
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *) a. SignalSource m a -> a -> Event m ()
triggerSignal (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> SignalSource m a
enqueueStoredSource Queue m si sm so a
q) (forall a. QueueItem a -> a
itemValue QueueItem a
i')
enqueueDeny :: MonadDES m
=> Queue m si sm so a
-> a
-> Event m ()
{-# INLINE enqueueDeny #-}
enqueueDeny :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> a -> Event m ()
enqueueDeny Queue m si sm so a
q a
a =
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event forall a b. (a -> b) -> a -> b
$ \Point m
p ->
do forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *) a.
MonadRef m =>
Ref m a -> (a -> a) -> Event m ()
modifyRef (forall (m :: * -> *) si sm so a. Queue m si sm so a -> Ref m Int
enqueueLostCountRef Queue m si sm so a
q) forall a b. (a -> b) -> a -> b
$ forall a. Num a => a -> a -> a
(+) Int
1
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *) a. SignalSource m a -> a -> Event m ()
triggerSignal (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> SignalSource m a
enqueueLostSource Queue m si sm so a
q) a
a
enqueueStat :: MonadDES m
=> Queue m si sm so a
-> QueueItem a
-> Event m ()
{-# INLINE enqueueStat #-}
enqueueStat :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> QueueItem a -> Event m ()
enqueueStat Queue m si sm so a
q QueueItem a
i =
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event forall a b. (a -> b) -> a -> b
$ \Point m
p ->
do let t0 :: Double
t0 = forall a. QueueItem a -> Double
itemInputTime QueueItem a
i
t1 :: Double
t1 = forall a. QueueItem a -> Double
itemStoringTime QueueItem a
i
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *) a.
MonadRef m =>
Ref m a -> (a -> a) -> Event m ()
modifyRef (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> Ref m (SamplingStats Double)
enqueueWaitTimeRef Queue m si sm so a
q) forall a b. (a -> b) -> a -> b
$
forall a. SamplingData a => a -> SamplingStats a -> SamplingStats a
addSamplingStats (Double
t1 forall a. Num a => a -> a -> a
- Double
t0)
dequeueRequest :: MonadDES m
=> Queue m si sm so a
-> Event m Double
{-# INLINE dequeueRequest #-}
dequeueRequest :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m Double
dequeueRequest Queue m si sm so a
q =
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event forall a b. (a -> b) -> a -> b
$ \Point m
p ->
do forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *) a.
MonadRef m =>
Ref m a -> (a -> a) -> Event m ()
modifyRef (forall (m :: * -> *) si sm so a. Queue m si sm so a -> Ref m Int
dequeueCountRef Queue m si sm so a
q) (forall a. Num a => a -> a -> a
+ Int
1)
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *) a. SignalSource m a -> a -> Event m ()
triggerSignal (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> SignalSource m ()
dequeueRequestedSource Queue m si sm so a
q) ()
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *). Point m -> Double
pointTime Point m
p
dequeueExtract :: (MonadDES m,
DequeueStrategy m si,
DequeueStrategy m sm)
=> Queue m si sm so a
-> Double
-> Event m a
{-# INLINE dequeueExtract #-}
Queue m si sm so a
q Double
t' =
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event forall a b. (a -> b) -> a -> b
$ \Point m
p ->
do QueueItem a
i <- forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *) s a.
DequeueStrategy m s =>
StrategyQueue m s a -> Event m a
strategyDequeue (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> StrategyQueue m sm (QueueItem a)
queueStore Queue m si sm so a
q)
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *) si sm so a.
(MonadDES m, DequeueStrategy m si, DequeueStrategy m sm) =>
Queue m si sm so a -> Double -> QueueItem a -> Event m a
dequeuePostExtract Queue m si sm so a
q Double
t' QueueItem a
i
dequeuePostExtract :: (MonadDES m,
DequeueStrategy m si,
DequeueStrategy m sm)
=> Queue m si sm so a
-> Double
-> QueueItem a
-> Event m a
{-# INLINE dequeuePostExtract #-}
Queue m si sm so a
q Double
t' QueueItem a
i =
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event forall a b. (a -> b) -> a -> b
$ \Point m
p ->
do Int
c <- forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (forall (m :: * -> *) si sm so a. Queue m si sm so a -> Ref m Int
queueCountRef Queue m si sm so a
q)
let c' :: Int
c' = Int
c forall a. Num a => a -> a -> a
- Int
1
t :: Double
t = forall (m :: * -> *). Point m -> Double
pointTime Point m
p
Int
c' seq :: forall a b. a -> b -> b
`seq` forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *) a. MonadRef m => Ref m a -> a -> Event m ()
writeRef (forall (m :: * -> *) si sm so a. Queue m si sm so a -> Ref m Int
queueCountRef Queue m si sm so a
q) Int
c'
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *) a.
MonadRef m =>
Ref m a -> (a -> a) -> Event m ()
modifyRef (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> Ref m (TimingStats Int)
queueCountStatsRef Queue m si sm so a
q) (forall a.
TimingData a =>
Double -> a -> TimingStats a -> TimingStats a
addTimingStats Double
t Int
c')
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *) a.
MonadRef m =>
Ref m a -> (a -> a) -> Event m ()
modifyRef (forall (m :: * -> *) si sm so a. Queue m si sm so a -> Ref m Int
dequeueExtractCountRef Queue m si sm so a
q) (forall a. Num a => a -> a -> a
+ Int
1)
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Double -> QueueItem a -> Event m ()
dequeueStat Queue m si sm so a
q Double
t' QueueItem a
i
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *) s.
(MonadDES m, DequeueStrategy m s) =>
Resource m s -> Event m ()
releaseResourceWithinEvent (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> Resource m si
enqueueRes Queue m si sm so a
q)
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *) a. SignalSource m a -> a -> Event m ()
triggerSignal (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> SignalSource m a
dequeueExtractedSource Queue m si sm so a
q) (forall a. QueueItem a -> a
itemValue QueueItem a
i)
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall a. QueueItem a -> a
itemValue QueueItem a
i
dequeueStat :: MonadDES m
=> Queue m si sm so a
-> Double
-> QueueItem a
-> Event m ()
{-# INLINE dequeueStat #-}
dequeueStat :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Double -> QueueItem a -> Event m ()
dequeueStat Queue m si sm so a
q Double
t' QueueItem a
i =
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event forall a b. (a -> b) -> a -> b
$ \Point m
p ->
do let t0 :: Double
t0 = forall a. QueueItem a -> Double
itemInputTime QueueItem a
i
t1 :: Double
t1 = forall a. QueueItem a -> Double
itemStoringTime QueueItem a
i
t :: Double
t = forall (m :: * -> *). Point m -> Double
pointTime Point m
p
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *) a.
MonadRef m =>
Ref m a -> (a -> a) -> Event m ()
modifyRef (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> Ref m (SamplingStats Double)
dequeueWaitTimeRef Queue m si sm so a
q) forall a b. (a -> b) -> a -> b
$
forall a. SamplingData a => a -> SamplingStats a -> SamplingStats a
addSamplingStats (Double
t forall a. Num a => a -> a -> a
- Double
t')
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *) a.
MonadRef m =>
Ref m a -> (a -> a) -> Event m ()
modifyRef (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> Ref m (SamplingStats Double)
queueTotalWaitTimeRef Queue m si sm so a
q) forall a b. (a -> b) -> a -> b
$
forall a. SamplingData a => a -> SamplingStats a -> SamplingStats a
addSamplingStats (Double
t forall a. Num a => a -> a -> a
- Double
t0)
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *) a.
MonadRef m =>
Ref m a -> (a -> a) -> Event m ()
modifyRef (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> Ref m (SamplingStats Double)
queueWaitTimeRef Queue m si sm so a
q) forall a b. (a -> b) -> a -> b
$
forall a. SamplingData a => a -> SamplingStats a -> SamplingStats a
addSamplingStats (Double
t forall a. Num a => a -> a -> a
- Double
t1)
waitWhileFullQueue :: MonadDES m => Queue m si sm so a -> Process m ()
{-# INLINABLE waitWhileFullQueue #-}
waitWhileFullQueue :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Process m ()
waitWhileFullQueue Queue m si sm so a
q =
do Bool
x <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
EventLift t m =>
Event m a -> t m a
liftEvent (forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m Bool
queueFull Queue m si sm so a
q)
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when Bool
x forall a b. (a -> b) -> a -> b
$
do forall (m :: * -> *) a. MonadDES m => Signal m a -> Process m a
processAwait (forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m a
dequeueExtracted Queue m si sm so a
q)
forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Process m ()
waitWhileFullQueue Queue m si sm so a
q
queueChanged_ :: MonadDES m => Queue m si sm so a -> Signal m ()
{-# INLINABLE queueChanged_ #-}
queueChanged_ :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m ()
queueChanged_ Queue m si sm so a
q =
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (forall a b. a -> b -> a
const ()) (forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m a
enqueueInitiated Queue m si sm so a
q) forall a. Semigroup a => a -> a -> a
<>
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (forall a b. a -> b -> a
const ()) (forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m a
enqueueStored Queue m si sm so a
q) forall a. Semigroup a => a -> a -> a
<>
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (forall a b. a -> b -> a
const ()) (forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m a
enqueueLost Queue m si sm so a
q) forall a. Semigroup a => a -> a -> a
<>
forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m ()
dequeueRequested Queue m si sm so a
q forall a. Semigroup a => a -> a -> a
<>
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (forall a b. a -> b -> a
const ()) (forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Signal m a
dequeueExtracted Queue m si sm so a
q)
queueSummary :: (MonadDES m, Show si, Show sm, Show so) => Queue m si sm so a -> Int -> Event m ShowS
{-# INLINABLE queueSummary #-}
queueSummary :: forall (m :: * -> *) si sm so a.
(MonadDES m, Show si, Show sm, Show so) =>
Queue m si sm so a -> Int -> Event m ShowS
queueSummary Queue m si sm so a
q Int
indent =
do let si :: si
si = forall (m :: * -> *) si sm so a. Queue m si sm so a -> si
enqueueStrategy Queue m si sm so a
q
sm :: sm
sm = forall (m :: * -> *) si sm so a. Queue m si sm so a -> sm
enqueueStoringStrategy Queue m si sm so a
q
so :: so
so = forall (m :: * -> *) si sm so a. Queue m si sm so a -> so
dequeueStrategy Queue m si sm so a
q
Bool
null <- forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m Bool
queueNull Queue m si sm so a
q
Bool
full <- forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m Bool
queueFull Queue m si sm so a
q
let maxCount :: Int
maxCount = forall (m :: * -> *) si sm so a. Queue m si sm so a -> Int
queueMaxCount Queue m si sm so a
q
Int
count <- forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m Int
queueCount Queue m si sm so a
q
TimingStats Int
countStats <- forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m (TimingStats Int)
queueCountStats Queue m si sm so a
q
Int
enqueueCount <- forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m Int
enqueueCount Queue m si sm so a
q
Int
enqueueLostCount <- forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m Int
enqueueLostCount Queue m si sm so a
q
Int
enqueueStoreCount <- forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m Int
enqueueStoreCount Queue m si sm so a
q
Int
dequeueCount <- forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m Int
dequeueCount Queue m si sm so a
q
Int
dequeueExtractCount <- forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m Int
dequeueExtractCount Queue m si sm so a
q
Double
loadFactor <- forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m Double
queueLoadFactor Queue m si sm so a
q
Double
enqueueRate <- forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m Double
enqueueRate Queue m si sm so a
q
Double
enqueueStoreRate <- forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m Double
enqueueStoreRate Queue m si sm so a
q
Double
dequeueRate <- forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m Double
dequeueRate Queue m si sm so a
q
Double
dequeueExtractRate <- forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m Double
dequeueExtractRate Queue m si sm so a
q
SamplingStats Double
waitTime <- forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m (SamplingStats Double)
queueWaitTime Queue m si sm so a
q
SamplingStats Double
totalWaitTime <- forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m (SamplingStats Double)
queueTotalWaitTime Queue m si sm so a
q
SamplingStats Double
enqueueWaitTime <- forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m (SamplingStats Double)
enqueueWaitTime Queue m si sm so a
q
SamplingStats Double
dequeueWaitTime <- forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m (SamplingStats Double)
dequeueWaitTime Queue m si sm so a
q
let tab :: [Char]
tab = forall a. Int -> a -> [a]
replicate Int
indent Char
' '
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$
[Char] -> ShowS
showString [Char]
tab forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"the enqueueing (input) strategy = " forall b c a. (b -> c) -> (a -> b) -> a -> c
.
forall a. Show a => a -> ShowS
shows si
si forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n" forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"the storing (memory) strategy = " forall b c a. (b -> c) -> (a -> b) -> a -> c
.
forall a. Show a => a -> ShowS
shows sm
sm forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n" forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"the dequeueing (output) strategy = " forall b c a. (b -> c) -> (a -> b) -> a -> c
.
forall a. Show a => a -> ShowS
shows so
so forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n" forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"empty? = " forall b c a. (b -> c) -> (a -> b) -> a -> c
.
forall a. Show a => a -> ShowS
shows Bool
null forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n" forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"full? = " forall b c a. (b -> c) -> (a -> b) -> a -> c
.
forall a. Show a => a -> ShowS
shows Bool
full forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n" forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"max. capacity = " forall b c a. (b -> c) -> (a -> b) -> a -> c
.
forall a. Show a => a -> ShowS
shows Int
maxCount forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n" forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"size = " forall b c a. (b -> c) -> (a -> b) -> a -> c
.
forall a. Show a => a -> ShowS
shows Int
count forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n" forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"the size statistics = \n\n" forall b c a. (b -> c) -> (a -> b) -> a -> c
.
forall a. (Show a, TimingData a) => TimingStats a -> Int -> ShowS
timingStatsSummary TimingStats Int
countStats (Int
2 forall a. Num a => a -> a -> a
+ Int
indent) forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n\n" forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"the enqueue count (number of the input items that were enqueued) = " forall b c a. (b -> c) -> (a -> b) -> a -> c
.
forall a. Show a => a -> ShowS
shows Int
enqueueCount forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n" forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"the enqueue lost count (number of the lost items) = " forall b c a. (b -> c) -> (a -> b) -> a -> c
.
forall a. Show a => a -> ShowS
shows Int
enqueueLostCount forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n" forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"the enqueue store count (number of the input items that were stored) = " forall b c a. (b -> c) -> (a -> b) -> a -> c
.
forall a. Show a => a -> ShowS
shows Int
enqueueStoreCount forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n" forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"the dequeue count (number of requests for dequeueing an item) = " forall b c a. (b -> c) -> (a -> b) -> a -> c
.
forall a. Show a => a -> ShowS
shows Int
dequeueCount forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n" forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"the dequeue extract count (number of the output items that were dequeued) = " forall b c a. (b -> c) -> (a -> b) -> a -> c
.
forall a. Show a => a -> ShowS
shows Int
dequeueExtractCount forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n" forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"the load factor (size / max. capacity) = " forall b c a. (b -> c) -> (a -> b) -> a -> c
.
forall a. Show a => a -> ShowS
shows Double
loadFactor forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n" forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"the enqueue rate (how many input items were enqueued per time) = " forall b c a. (b -> c) -> (a -> b) -> a -> c
.
forall a. Show a => a -> ShowS
shows Double
enqueueRate forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n" forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"the enqueue store rate (how many input items were stored per time) = " forall b c a. (b -> c) -> (a -> b) -> a -> c
.
forall a. Show a => a -> ShowS
shows Double
enqueueStoreRate forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n" forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"the dequeue rate (how many requests for dequeueing per time) = " forall b c a. (b -> c) -> (a -> b) -> a -> c
.
forall a. Show a => a -> ShowS
shows Double
dequeueRate forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n" forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"the dequeue extract rate (how many output items were dequeued per time) = " forall b c a. (b -> c) -> (a -> b) -> a -> c
.
forall a. Show a => a -> ShowS
shows Double
dequeueExtractRate forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n" forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"the wait time (when was stored -> when was dequeued) = \n\n" forall b c a. (b -> c) -> (a -> b) -> a -> c
.
forall a. Show a => SamplingStats a -> Int -> ShowS
samplingStatsSummary SamplingStats Double
waitTime (Int
2 forall a. Num a => a -> a -> a
+ Int
indent) forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n\n" forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"the total wait time (when the enqueueing was initiated -> when was dequeued) = \n\n" forall b c a. (b -> c) -> (a -> b) -> a -> c
.
forall a. Show a => SamplingStats a -> Int -> ShowS
samplingStatsSummary SamplingStats Double
totalWaitTime (Int
2 forall a. Num a => a -> a -> a
+ Int
indent) forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n\n" forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"the enqueue wait time (when the enqueueing was initiated -> when was stored) = \n\n" forall b c a. (b -> c) -> (a -> b) -> a -> c
.
forall a. Show a => SamplingStats a -> Int -> ShowS
samplingStatsSummary SamplingStats Double
enqueueWaitTime (Int
2 forall a. Num a => a -> a -> a
+ Int
indent) forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n\n" forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"the dequeue wait time (when was requested for dequeueing -> when was dequeued) = \n\n" forall b c a. (b -> c) -> (a -> b) -> a -> c
.
forall a. Show a => SamplingStats a -> Int -> ShowS
samplingStatsSummary SamplingStats Double
dequeueWaitTime (Int
2 forall a. Num a => a -> a -> a
+ Int
indent)
resetQueue :: MonadDES m => Queue m si sm so a -> Event m ()
{-# INLINABLE resetQueue #-}
resetQueue :: forall (m :: * -> *) si sm so a.
MonadDES m =>
Queue m si sm so a -> Event m ()
resetQueue Queue m si sm so a
q =
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event forall a b. (a -> b) -> a -> b
$ \Point m
p ->
do let t :: Double
t = forall (m :: * -> *). Point m -> Double
pointTime Point m
p
Int
queueCount <- forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (forall (m :: * -> *) si sm so a. Queue m si sm so a -> Ref m Int
queueCountRef Queue m si sm so a
q)
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadRef m => Ref m a -> a -> Event m ()
writeRef (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> Ref m (TimingStats Int)
queueCountStatsRef Queue m si sm so a
q) forall a b. (a -> b) -> a -> b
$
forall a. TimingData a => Double -> a -> TimingStats a
returnTimingStats Double
t Int
queueCount
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadRef m => Ref m a -> a -> Event m ()
writeRef (forall (m :: * -> *) si sm so a. Queue m si sm so a -> Ref m Int
enqueueCountRef Queue m si sm so a
q) Int
0
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadRef m => Ref m a -> a -> Event m ()
writeRef (forall (m :: * -> *) si sm so a. Queue m si sm so a -> Ref m Int
enqueueLostCountRef Queue m si sm so a
q) Int
0
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadRef m => Ref m a -> a -> Event m ()
writeRef (forall (m :: * -> *) si sm so a. Queue m si sm so a -> Ref m Int
enqueueStoreCountRef Queue m si sm so a
q) Int
0
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadRef m => Ref m a -> a -> Event m ()
writeRef (forall (m :: * -> *) si sm so a. Queue m si sm so a -> Ref m Int
dequeueCountRef Queue m si sm so a
q) Int
0
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadRef m => Ref m a -> a -> Event m ()
writeRef (forall (m :: * -> *) si sm so a. Queue m si sm so a -> Ref m Int
dequeueExtractCountRef Queue m si sm so a
q) Int
0
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadRef m => Ref m a -> a -> Event m ()
writeRef (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> Ref m (SamplingStats Double)
queueWaitTimeRef Queue m si sm so a
q) forall a. Monoid a => a
mempty
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadRef m => Ref m a -> a -> Event m ()
writeRef (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> Ref m (SamplingStats Double)
queueTotalWaitTimeRef Queue m si sm so a
q) forall a. Monoid a => a
mempty
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadRef m => Ref m a -> a -> Event m ()
writeRef (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> Ref m (SamplingStats Double)
enqueueWaitTimeRef Queue m si sm so a
q) forall a. Monoid a => a
mempty
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadRef m => Ref m a -> a -> Event m ()
writeRef (forall (m :: * -> *) si sm so a.
Queue m si sm so a -> Ref m (SamplingStats Double)
dequeueWaitTimeRef Queue m si sm so a
q) forall a. Monoid a => a
mempty