{-# LANGUAGE FlexibleContexts #-}
module Simulation.Aivika.Trans.Queue.Infinite
(
FCFSQueue,
LCFSQueue,
SIROQueue,
PriorityQueue,
Queue,
newFCFSQueue,
newLCFSQueue,
newSIROQueue,
newPriorityQueue,
newQueue,
enqueueStoringStrategy,
dequeueStrategy,
queueNull,
queueCount,
queueCountStats,
enqueueStoreCount,
dequeueCount,
dequeueExtractCount,
enqueueStoreRate,
dequeueRate,
dequeueExtractRate,
queueWaitTime,
dequeueWaitTime,
queueRate,
dequeue,
dequeueWithOutputPriority,
tryDequeue,
enqueue,
enqueueWithStoringPriority,
queueDelete,
queueDelete_,
queueDeleteBy,
queueDeleteBy_,
queueContains,
queueContainsBy,
clearQueue,
resetQueue,
queueSummary,
queueNullChanged,
queueNullChanged_,
queueCountChanged,
queueCountChanged_,
enqueueStoreCountChanged,
enqueueStoreCountChanged_,
dequeueCountChanged,
dequeueCountChanged_,
dequeueExtractCountChanged,
dequeueExtractCountChanged_,
queueWaitTimeChanged,
queueWaitTimeChanged_,
dequeueWaitTimeChanged,
dequeueWaitTimeChanged_,
queueRateChanged,
queueRateChanged_,
enqueueStored,
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 a
type LCFSQueue m a = Queue m LCFS FCFS a
type SIROQueue m a = Queue m SIRO FCFS a
type PriorityQueue m a = Queue m StaticPriorities FCFS a
data Queue m sm so a =
Queue { forall (m :: * -> *) sm so a. Queue m sm so a -> sm
enqueueStoringStrategy :: sm,
forall (m :: * -> *) sm so a. Queue m sm so a -> so
dequeueStrategy :: so,
forall (m :: * -> *) sm so a.
Queue m sm so a -> StrategyQueue m sm (QueueItem a)
queueStore :: StrategyQueue m sm (QueueItem a),
forall (m :: * -> *) sm so a. Queue m sm so a -> Resource m so
dequeueRes :: Resource m so,
forall (m :: * -> *) sm so a. Queue m sm so a -> Ref m Int
queueCountRef :: Ref m Int,
forall (m :: * -> *) sm so a.
Queue m sm so a -> Ref m (TimingStats Int)
queueCountStatsRef :: Ref m (TimingStats Int),
forall (m :: * -> *) sm so a. Queue m sm so a -> Ref m Int
enqueueStoreCountRef :: Ref m Int,
forall (m :: * -> *) sm so a. Queue m sm so a -> Ref m Int
dequeueCountRef :: Ref m Int,
:: Ref m Int,
forall (m :: * -> *) sm so a.
Queue m sm so a -> Ref m (SamplingStats Double)
queueWaitTimeRef :: Ref m (SamplingStats Double),
forall (m :: * -> *) sm so a.
Queue m sm so a -> Ref m (SamplingStats Double)
dequeueWaitTimeRef :: Ref m (SamplingStats Double),
forall (m :: * -> *) sm so a. Queue m sm so a -> SignalSource m a
enqueueStoredSource :: SignalSource m a,
forall (m :: * -> *) sm so a. Queue m 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
itemStoringTime :: Double
}
newFCFSQueue :: MonadDES m => Event m (FCFSQueue m a)
{-# INLINABLE newFCFSQueue #-}
newFCFSQueue :: forall (m :: * -> *) a. MonadDES m => Event m (FCFSQueue m a)
newFCFSQueue = FCFS -> FCFS -> Event m (Queue m FCFS FCFS a)
forall (m :: * -> *) sm so a.
(MonadDES m, QueueStrategy m sm, QueueStrategy m so) =>
sm -> so -> Event m (Queue m sm so a)
newQueue FCFS
FCFS FCFS
FCFS
newLCFSQueue :: MonadDES m => Event m (LCFSQueue m a)
{-# INLINABLE newLCFSQueue #-}
newLCFSQueue :: forall (m :: * -> *) a. MonadDES m => Event m (LCFSQueue m a)
newLCFSQueue = LCFS -> FCFS -> Event m (Queue m LCFS FCFS a)
forall (m :: * -> *) sm so a.
(MonadDES m, QueueStrategy m sm, QueueStrategy m so) =>
sm -> so -> Event m (Queue m sm so a)
newQueue LCFS
LCFS FCFS
FCFS
newSIROQueue :: (MonadDES m, QueueStrategy m SIRO) => Event m (SIROQueue m a)
{-# INLINABLE newSIROQueue #-}
newSIROQueue :: forall (m :: * -> *) a.
(MonadDES m, QueueStrategy m SIRO) =>
Event m (SIROQueue m a)
newSIROQueue = SIRO -> FCFS -> Event m (Queue m SIRO FCFS a)
forall (m :: * -> *) sm so a.
(MonadDES m, QueueStrategy m sm, QueueStrategy m so) =>
sm -> so -> Event m (Queue m sm so a)
newQueue SIRO
SIRO FCFS
FCFS
newPriorityQueue :: (MonadDES m, QueueStrategy m StaticPriorities) => Event m (PriorityQueue m a)
{-# INLINABLE newPriorityQueue #-}
newPriorityQueue :: forall (m :: * -> *) a.
(MonadDES m, QueueStrategy m StaticPriorities) =>
Event m (PriorityQueue m a)
newPriorityQueue = StaticPriorities
-> FCFS -> Event m (Queue m StaticPriorities FCFS a)
forall (m :: * -> *) sm so a.
(MonadDES m, QueueStrategy m sm, QueueStrategy m so) =>
sm -> so -> Event m (Queue m sm so a)
newQueue StaticPriorities
StaticPriorities FCFS
FCFS
newQueue :: (MonadDES m,
QueueStrategy m sm,
QueueStrategy m so) =>
sm
-> so
-> Event m (Queue m sm so a)
{-# INLINABLE newQueue #-}
newQueue :: forall (m :: * -> *) sm so a.
(MonadDES m, QueueStrategy m sm, QueueStrategy m so) =>
sm -> so -> Event m (Queue m sm so a)
newQueue sm
sm so
so =
do Double
t <- Dynamics m Double -> Event m Double
forall a. Dynamics m a -> Event m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
DynamicsLift t m =>
Dynamics m a -> t m a
liftDynamics Dynamics m Double
forall (m :: * -> *). Monad m => Dynamics m Double
time
Ref m Int
i <- Simulation m (Ref m Int) -> Event m (Ref m Int)
forall a. Simulation m a -> Event m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
SimulationLift t m =>
Simulation m a -> t m a
liftSimulation (Simulation m (Ref m Int) -> Event m (Ref m Int))
-> Simulation m (Ref m Int) -> Event m (Ref m Int)
forall a b. (a -> b) -> a -> b
$ Int -> Simulation m (Ref m Int)
forall a. a -> Simulation m (Ref m a)
forall (m :: * -> *) a. MonadRef m => a -> Simulation m (Ref m a)
newRef Int
0
Ref m (TimingStats Int)
is <- Simulation m (Ref m (TimingStats Int))
-> Event m (Ref m (TimingStats Int))
forall a. Simulation m a -> Event m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
SimulationLift t m =>
Simulation m a -> t m a
liftSimulation (Simulation m (Ref m (TimingStats Int))
-> Event m (Ref m (TimingStats Int)))
-> Simulation m (Ref m (TimingStats Int))
-> Event m (Ref m (TimingStats Int))
forall a b. (a -> b) -> a -> b
$ TimingStats Int -> Simulation m (Ref m (TimingStats Int))
forall a. a -> Simulation m (Ref m a)
forall (m :: * -> *) a. MonadRef m => a -> Simulation m (Ref m a)
newRef (TimingStats Int -> Simulation m (Ref m (TimingStats Int)))
-> TimingStats Int -> Simulation m (Ref m (TimingStats Int))
forall a b. (a -> b) -> a -> b
$ Double -> Int -> TimingStats Int
forall a. TimingData a => Double -> a -> TimingStats a
returnTimingStats Double
t Int
0
Ref m Int
cm <- Simulation m (Ref m Int) -> Event m (Ref m Int)
forall a. Simulation m a -> Event m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
SimulationLift t m =>
Simulation m a -> t m a
liftSimulation (Simulation m (Ref m Int) -> Event m (Ref m Int))
-> Simulation m (Ref m Int) -> Event m (Ref m Int)
forall a b. (a -> b) -> a -> b
$ Int -> Simulation m (Ref m Int)
forall a. a -> Simulation m (Ref m a)
forall (m :: * -> *) a. MonadRef m => a -> Simulation m (Ref m a)
newRef Int
0
Ref m Int
cr <- Simulation m (Ref m Int) -> Event m (Ref m Int)
forall a. Simulation m a -> Event m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
SimulationLift t m =>
Simulation m a -> t m a
liftSimulation (Simulation m (Ref m Int) -> Event m (Ref m Int))
-> Simulation m (Ref m Int) -> Event m (Ref m Int)
forall a b. (a -> b) -> a -> b
$ Int -> Simulation m (Ref m Int)
forall a. a -> Simulation m (Ref m a)
forall (m :: * -> *) a. MonadRef m => a -> Simulation m (Ref m a)
newRef Int
0
Ref m Int
co <- Simulation m (Ref m Int) -> Event m (Ref m Int)
forall a. Simulation m a -> Event m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
SimulationLift t m =>
Simulation m a -> t m a
liftSimulation (Simulation m (Ref m Int) -> Event m (Ref m Int))
-> Simulation m (Ref m Int) -> Event m (Ref m Int)
forall a b. (a -> b) -> a -> b
$ Int -> Simulation m (Ref m Int)
forall a. a -> Simulation m (Ref m a)
forall (m :: * -> *) a. MonadRef m => a -> Simulation m (Ref m a)
newRef Int
0
StrategyQueue m sm (QueueItem a)
qm <- Simulation m (StrategyQueue m sm (QueueItem a))
-> Event m (StrategyQueue m sm (QueueItem a))
forall a. Simulation m a -> Event m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
SimulationLift t m =>
Simulation m a -> t m a
liftSimulation (Simulation m (StrategyQueue m sm (QueueItem a))
-> Event m (StrategyQueue m sm (QueueItem a)))
-> Simulation m (StrategyQueue m sm (QueueItem a))
-> Event m (StrategyQueue m sm (QueueItem a))
forall a b. (a -> b) -> a -> b
$ sm -> Simulation m (StrategyQueue m sm (QueueItem a))
forall a. sm -> Simulation m (StrategyQueue m sm a)
forall (m :: * -> *) s a.
QueueStrategy m s =>
s -> Simulation m (StrategyQueue m s a)
newStrategyQueue sm
sm
Resource m so
ro <- Simulation m (Resource m so) -> Event m (Resource m so)
forall a. Simulation m a -> Event m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
SimulationLift t m =>
Simulation m a -> t m a
liftSimulation (Simulation m (Resource m so) -> Event m (Resource m so))
-> Simulation m (Resource m so) -> Event m (Resource m so)
forall a b. (a -> b) -> a -> b
$ so -> Int -> Maybe Int -> Simulation m (Resource m so)
forall (m :: * -> *) s.
(MonadDES m, QueueStrategy m s) =>
s -> Int -> Maybe Int -> Simulation m (Resource m s)
newResourceWithMaxCount so
so Int
0 Maybe Int
forall a. Maybe a
Nothing
Ref m (SamplingStats Double)
w <- Simulation m (Ref m (SamplingStats Double))
-> Event m (Ref m (SamplingStats Double))
forall a. Simulation m a -> Event m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
SimulationLift t m =>
Simulation m a -> t m a
liftSimulation (Simulation m (Ref m (SamplingStats Double))
-> Event m (Ref m (SamplingStats Double)))
-> Simulation m (Ref m (SamplingStats Double))
-> Event m (Ref m (SamplingStats Double))
forall a b. (a -> b) -> a -> b
$ SamplingStats Double -> Simulation m (Ref m (SamplingStats Double))
forall a. a -> Simulation m (Ref m a)
forall (m :: * -> *) a. MonadRef m => a -> Simulation m (Ref m a)
newRef SamplingStats Double
forall a. Monoid a => a
mempty
Ref m (SamplingStats Double)
wo <- Simulation m (Ref m (SamplingStats Double))
-> Event m (Ref m (SamplingStats Double))
forall a. Simulation m a -> Event m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
SimulationLift t m =>
Simulation m a -> t m a
liftSimulation (Simulation m (Ref m (SamplingStats Double))
-> Event m (Ref m (SamplingStats Double)))
-> Simulation m (Ref m (SamplingStats Double))
-> Event m (Ref m (SamplingStats Double))
forall a b. (a -> b) -> a -> b
$ SamplingStats Double -> Simulation m (Ref m (SamplingStats Double))
forall a. a -> Simulation m (Ref m a)
forall (m :: * -> *) a. MonadRef m => a -> Simulation m (Ref m a)
newRef SamplingStats Double
forall a. Monoid a => a
mempty
SignalSource m a
s3 <- Simulation m (SignalSource m a) -> Event m (SignalSource m a)
forall a. Simulation m a -> Event m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
SimulationLift t m =>
Simulation m a -> t m a
liftSimulation Simulation m (SignalSource m a)
forall (m :: * -> *) a.
MonadDES m =>
Simulation m (SignalSource m a)
newSignalSource
SignalSource m ()
s4 <- Simulation m (SignalSource m ()) -> Event m (SignalSource m ())
forall a. Simulation m a -> Event m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
SimulationLift t m =>
Simulation m a -> t m a
liftSimulation Simulation m (SignalSource m ())
forall (m :: * -> *) a.
MonadDES m =>
Simulation m (SignalSource m a)
newSignalSource
SignalSource m a
s5 <- Simulation m (SignalSource m a) -> Event m (SignalSource m a)
forall a. Simulation m a -> Event m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
SimulationLift t m =>
Simulation m a -> t m a
liftSimulation Simulation m (SignalSource m a)
forall (m :: * -> *) a.
MonadDES m =>
Simulation m (SignalSource m a)
newSignalSource
Queue m sm so a -> Event m (Queue m sm so a)
forall a. a -> Event m a
forall (m :: * -> *) a. Monad m => a -> m a
return Queue { enqueueStoringStrategy :: sm
enqueueStoringStrategy = sm
sm,
dequeueStrategy :: so
dequeueStrategy = so
so,
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,
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,
dequeueWaitTimeRef :: Ref m (SamplingStats Double)
dequeueWaitTimeRef = Ref m (SamplingStats Double)
wo,
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 sm so a -> Event m Bool
{-# INLINABLE queueNull #-}
queueNull :: forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Event m Bool
queueNull Queue m sm so a
q =
(Point m -> m Bool) -> Event m Bool
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event ((Point m -> m Bool) -> Event m Bool)
-> (Point m -> m Bool) -> Event m Bool
forall a b. (a -> b) -> a -> b
$ \Point m
p ->
do Int
n <- Point m -> Event m Int -> m Int
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m Int -> m Int) -> Event m Int -> m Int
forall a b. (a -> b) -> a -> b
$ Ref m Int -> Event m Int
forall a. Ref m a -> Event m a
forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (Queue m sm so a -> Ref m Int
forall (m :: * -> *) sm so a. Queue m sm so a -> Ref m Int
queueCountRef Queue m sm so a
q)
Bool -> m Bool
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Int
n Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
0)
queueNullChanged :: MonadDES m => Queue m sm so a -> Signal m Bool
{-# INLINABLE queueNullChanged #-}
queueNullChanged :: forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Signal m Bool
queueNullChanged Queue m sm so a
q =
(() -> Event m Bool) -> Signal m () -> Signal m Bool
forall (m :: * -> *) a b.
MonadDES m =>
(a -> Event m b) -> Signal m a -> Signal m b
mapSignalM (Event m Bool -> () -> Event m Bool
forall a b. a -> b -> a
const (Event m Bool -> () -> Event m Bool)
-> Event m Bool -> () -> Event m Bool
forall a b. (a -> b) -> a -> b
$ Queue m sm so a -> Event m Bool
forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Event m Bool
queueNull Queue m sm so a
q) (Queue m sm so a -> Signal m ()
forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Signal m ()
queueNullChanged_ Queue m sm so a
q)
queueNullChanged_ :: MonadDES m => Queue m sm so a -> Signal m ()
{-# INLINABLE queueNullChanged_ #-}
queueNullChanged_ :: forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Signal m ()
queueNullChanged_ = Queue m sm so a -> Signal m ()
forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Signal m ()
queueCountChanged_
queueCount :: MonadDES m => Queue m sm so a -> Event m Int
{-# INLINABLE queueCount #-}
queueCount :: forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Event m Int
queueCount Queue m sm so a
q =
(Point m -> m Int) -> Event m Int
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event ((Point m -> m Int) -> Event m Int)
-> (Point m -> m Int) -> Event m Int
forall a b. (a -> b) -> a -> b
$ \Point m
p -> Point m -> Event m Int -> m Int
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m Int -> m Int) -> Event m Int -> m Int
forall a b. (a -> b) -> a -> b
$ Ref m Int -> Event m Int
forall a. Ref m a -> Event m a
forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (Queue m sm so a -> Ref m Int
forall (m :: * -> *) sm so a. Queue m sm so a -> Ref m Int
queueCountRef Queue m sm so a
q)
queueCountStats :: MonadDES m => Queue m sm so a -> Event m (TimingStats Int)
{-# INLINABLE queueCountStats #-}
queueCountStats :: forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Event m (TimingStats Int)
queueCountStats Queue m sm so a
q =
(Point m -> m (TimingStats Int)) -> Event m (TimingStats Int)
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event ((Point m -> m (TimingStats Int)) -> Event m (TimingStats Int))
-> (Point m -> m (TimingStats Int)) -> Event m (TimingStats Int)
forall a b. (a -> b) -> a -> b
$ \Point m
p -> Point m -> Event m (TimingStats Int) -> m (TimingStats Int)
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m (TimingStats Int) -> m (TimingStats Int))
-> Event m (TimingStats Int) -> m (TimingStats Int)
forall a b. (a -> b) -> a -> b
$ Ref m (TimingStats Int) -> Event m (TimingStats Int)
forall a. Ref m a -> Event m a
forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (Queue m sm so a -> Ref m (TimingStats Int)
forall (m :: * -> *) sm so a.
Queue m sm so a -> Ref m (TimingStats Int)
queueCountStatsRef Queue m sm so a
q)
queueCountChanged :: MonadDES m => Queue m sm so a -> Signal m Int
{-# INLINABLE queueCountChanged #-}
queueCountChanged :: forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Signal m Int
queueCountChanged Queue m sm so a
q =
(() -> Event m Int) -> Signal m () -> Signal m Int
forall (m :: * -> *) a b.
MonadDES m =>
(a -> Event m b) -> Signal m a -> Signal m b
mapSignalM (Event m Int -> () -> Event m Int
forall a b. a -> b -> a
const (Event m Int -> () -> Event m Int)
-> Event m Int -> () -> Event m Int
forall a b. (a -> b) -> a -> b
$ Queue m sm so a -> Event m Int
forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Event m Int
queueCount Queue m sm so a
q) (Queue m sm so a -> Signal m ()
forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Signal m ()
queueCountChanged_ Queue m sm so a
q)
queueCountChanged_ :: MonadDES m => Queue m sm so a -> Signal m ()
{-# INLINABLE queueCountChanged_ #-}
queueCountChanged_ :: forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Signal m ()
queueCountChanged_ Queue m sm so a
q =
(a -> ()) -> Signal m a -> Signal m ()
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (() -> a -> ()
forall a b. a -> b -> a
const ()) (Queue m sm so a -> Signal m a
forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Signal m a
enqueueStored Queue m sm so a
q) Signal m () -> Signal m () -> Signal m ()
forall a. Semigroup a => a -> a -> a
<>
(a -> ()) -> Signal m a -> Signal m ()
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (() -> a -> ()
forall a b. a -> b -> a
const ()) (Queue m sm so a -> Signal m a
forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Signal m a
dequeueExtracted Queue m sm so a
q)
enqueueStoreCount :: MonadDES m => Queue m sm so a -> Event m Int
{-# INLINABLE enqueueStoreCount #-}
enqueueStoreCount :: forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Event m Int
enqueueStoreCount Queue m sm so a
q =
(Point m -> m Int) -> Event m Int
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event ((Point m -> m Int) -> Event m Int)
-> (Point m -> m Int) -> Event m Int
forall a b. (a -> b) -> a -> b
$ \Point m
p -> Point m -> Event m Int -> m Int
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m Int -> m Int) -> Event m Int -> m Int
forall a b. (a -> b) -> a -> b
$ Ref m Int -> Event m Int
forall a. Ref m a -> Event m a
forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (Queue m sm so a -> Ref m Int
forall (m :: * -> *) sm so a. Queue m sm so a -> Ref m Int
enqueueStoreCountRef Queue m sm so a
q)
enqueueStoreCountChanged :: MonadDES m => Queue m sm so a -> Signal m Int
{-# INLINABLE enqueueStoreCountChanged #-}
enqueueStoreCountChanged :: forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Signal m Int
enqueueStoreCountChanged Queue m sm so a
q =
(() -> Event m Int) -> Signal m () -> Signal m Int
forall (m :: * -> *) a b.
MonadDES m =>
(a -> Event m b) -> Signal m a -> Signal m b
mapSignalM (Event m Int -> () -> Event m Int
forall a b. a -> b -> a
const (Event m Int -> () -> Event m Int)
-> Event m Int -> () -> Event m Int
forall a b. (a -> b) -> a -> b
$ Queue m sm so a -> Event m Int
forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Event m Int
enqueueStoreCount Queue m sm so a
q) (Queue m sm so a -> Signal m ()
forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Signal m ()
enqueueStoreCountChanged_ Queue m sm so a
q)
enqueueStoreCountChanged_ :: MonadDES m => Queue m sm so a -> Signal m ()
{-# INLINABLE enqueueStoreCountChanged_ #-}
enqueueStoreCountChanged_ :: forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Signal m ()
enqueueStoreCountChanged_ Queue m sm so a
q =
(a -> ()) -> Signal m a -> Signal m ()
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (() -> a -> ()
forall a b. a -> b -> a
const ()) (Queue m sm so a -> Signal m a
forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Signal m a
enqueueStored Queue m sm so a
q)
dequeueCount :: MonadDES m => Queue m sm so a -> Event m Int
{-# INLINABLE dequeueCount #-}
dequeueCount :: forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Event m Int
dequeueCount Queue m sm so a
q =
(Point m -> m Int) -> Event m Int
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event ((Point m -> m Int) -> Event m Int)
-> (Point m -> m Int) -> Event m Int
forall a b. (a -> b) -> a -> b
$ \Point m
p -> Point m -> Event m Int -> m Int
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m Int -> m Int) -> Event m Int -> m Int
forall a b. (a -> b) -> a -> b
$ Ref m Int -> Event m Int
forall a. Ref m a -> Event m a
forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (Queue m sm so a -> Ref m Int
forall (m :: * -> *) sm so a. Queue m sm so a -> Ref m Int
dequeueCountRef Queue m sm so a
q)
dequeueCountChanged :: MonadDES m => Queue m sm so a -> Signal m Int
{-# INLINABLE dequeueCountChanged #-}
dequeueCountChanged :: forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Signal m Int
dequeueCountChanged Queue m sm so a
q =
(() -> Event m Int) -> Signal m () -> Signal m Int
forall (m :: * -> *) a b.
MonadDES m =>
(a -> Event m b) -> Signal m a -> Signal m b
mapSignalM (Event m Int -> () -> Event m Int
forall a b. a -> b -> a
const (Event m Int -> () -> Event m Int)
-> Event m Int -> () -> Event m Int
forall a b. (a -> b) -> a -> b
$ Queue m sm so a -> Event m Int
forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Event m Int
dequeueCount Queue m sm so a
q) (Queue m sm so a -> Signal m ()
forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Signal m ()
dequeueCountChanged_ Queue m sm so a
q)
dequeueCountChanged_ :: MonadDES m => Queue m sm so a -> Signal m ()
{-# INLINABLE dequeueCountChanged_ #-}
dequeueCountChanged_ :: forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Signal m ()
dequeueCountChanged_ Queue m sm so a
q =
(() -> ()) -> Signal m () -> Signal m ()
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (() -> () -> ()
forall a b. a -> b -> a
const ()) (Queue m sm so a -> Signal m ()
forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Signal m ()
dequeueRequested Queue m sm so a
q)
dequeueExtractCount :: MonadDES m => Queue m sm so a -> Event m Int
{-# INLINABLE dequeueExtractCount #-}
Queue m sm so a
q =
(Point m -> m Int) -> Event m Int
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event ((Point m -> m Int) -> Event m Int)
-> (Point m -> m Int) -> Event m Int
forall a b. (a -> b) -> a -> b
$ \Point m
p -> Point m -> Event m Int -> m Int
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m Int -> m Int) -> Event m Int -> m Int
forall a b. (a -> b) -> a -> b
$ Ref m Int -> Event m Int
forall a. Ref m a -> Event m a
forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (Queue m sm so a -> Ref m Int
forall (m :: * -> *) sm so a. Queue m sm so a -> Ref m Int
dequeueExtractCountRef Queue m sm so a
q)
dequeueExtractCountChanged :: MonadDES m => Queue m sm so a -> Signal m Int
{-# INLINABLE dequeueExtractCountChanged #-}
Queue m sm so a
q =
(() -> Event m Int) -> Signal m () -> Signal m Int
forall (m :: * -> *) a b.
MonadDES m =>
(a -> Event m b) -> Signal m a -> Signal m b
mapSignalM (Event m Int -> () -> Event m Int
forall a b. a -> b -> a
const (Event m Int -> () -> Event m Int)
-> Event m Int -> () -> Event m Int
forall a b. (a -> b) -> a -> b
$ Queue m sm so a -> Event m Int
forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Event m Int
dequeueExtractCount Queue m sm so a
q) (Queue m sm so a -> Signal m ()
forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Signal m ()
dequeueExtractCountChanged_ Queue m sm so a
q)
dequeueExtractCountChanged_ :: MonadDES m => Queue m sm so a -> Signal m ()
{-# INLINABLE dequeueExtractCountChanged_ #-}
Queue m sm so a
q =
(a -> ()) -> Signal m a -> Signal m ()
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (() -> a -> ()
forall a b. a -> b -> a
const ()) (Queue m sm so a -> Signal m a
forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Signal m a
dequeueExtracted Queue m sm so a
q)
enqueueStoreRate :: MonadDES m => Queue m sm so a -> Event m Double
{-# INLINABLE enqueueStoreRate #-}
enqueueStoreRate :: forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Event m Double
enqueueStoreRate Queue m sm so a
q =
(Point m -> m Double) -> Event m Double
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event ((Point m -> m Double) -> Event m Double)
-> (Point m -> m Double) -> Event m Double
forall a b. (a -> b) -> a -> b
$ \Point m
p ->
do Int
x <- Point m -> Event m Int -> m Int
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m Int -> m Int) -> Event m Int -> m Int
forall a b. (a -> b) -> a -> b
$ Ref m Int -> Event m Int
forall a. Ref m a -> Event m a
forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (Queue m sm so a -> Ref m Int
forall (m :: * -> *) sm so a. Queue m sm so a -> Ref m Int
enqueueStoreCountRef Queue m sm so a
q)
let t0 :: Double
t0 = Specs m -> Double
forall (m :: * -> *). Specs m -> Double
spcStartTime (Specs m -> Double) -> Specs m -> Double
forall a b. (a -> b) -> a -> b
$ Point m -> Specs m
forall (m :: * -> *). Point m -> Specs m
pointSpecs Point m
p
t :: Double
t = Point m -> Double
forall (m :: * -> *). Point m -> Double
pointTime Point m
p
Double -> m Double
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Int -> Double
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
x Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/ (Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
t0))
dequeueRate :: MonadDES m => Queue m sm so a -> Event m Double
{-# INLINABLE dequeueRate #-}
dequeueRate :: forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Event m Double
dequeueRate Queue m sm so a
q =
(Point m -> m Double) -> Event m Double
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event ((Point m -> m Double) -> Event m Double)
-> (Point m -> m Double) -> Event m Double
forall a b. (a -> b) -> a -> b
$ \Point m
p ->
do Int
x <- Point m -> Event m Int -> m Int
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m Int -> m Int) -> Event m Int -> m Int
forall a b. (a -> b) -> a -> b
$ Ref m Int -> Event m Int
forall a. Ref m a -> Event m a
forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (Queue m sm so a -> Ref m Int
forall (m :: * -> *) sm so a. Queue m sm so a -> Ref m Int
dequeueCountRef Queue m sm so a
q)
let t0 :: Double
t0 = Specs m -> Double
forall (m :: * -> *). Specs m -> Double
spcStartTime (Specs m -> Double) -> Specs m -> Double
forall a b. (a -> b) -> a -> b
$ Point m -> Specs m
forall (m :: * -> *). Point m -> Specs m
pointSpecs Point m
p
t :: Double
t = Point m -> Double
forall (m :: * -> *). Point m -> Double
pointTime Point m
p
Double -> m Double
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Int -> Double
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
x Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/ (Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
t0))
dequeueExtractRate :: MonadDES m => Queue m sm so a -> Event m Double
{-# INLINABLE dequeueExtractRate #-}
Queue m sm so a
q =
(Point m -> m Double) -> Event m Double
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event ((Point m -> m Double) -> Event m Double)
-> (Point m -> m Double) -> Event m Double
forall a b. (a -> b) -> a -> b
$ \Point m
p ->
do Int
x <- Point m -> Event m Int -> m Int
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m Int -> m Int) -> Event m Int -> m Int
forall a b. (a -> b) -> a -> b
$ Ref m Int -> Event m Int
forall a. Ref m a -> Event m a
forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (Queue m sm so a -> Ref m Int
forall (m :: * -> *) sm so a. Queue m sm so a -> Ref m Int
dequeueExtractCountRef Queue m sm so a
q)
let t0 :: Double
t0 = Specs m -> Double
forall (m :: * -> *). Specs m -> Double
spcStartTime (Specs m -> Double) -> Specs m -> Double
forall a b. (a -> b) -> a -> b
$ Point m -> Specs m
forall (m :: * -> *). Point m -> Specs m
pointSpecs Point m
p
t :: Double
t = Point m -> Double
forall (m :: * -> *). Point m -> Double
pointTime Point m
p
Double -> m Double
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Int -> Double
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
x Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/ (Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
t0))
queueWaitTime :: MonadDES m => Queue m sm so a -> Event m (SamplingStats Double)
{-# INLINABLE queueWaitTime #-}
queueWaitTime :: forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Event m (SamplingStats Double)
queueWaitTime Queue m sm so a
q =
(Point m -> m (SamplingStats Double))
-> Event m (SamplingStats Double)
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event ((Point m -> m (SamplingStats Double))
-> Event m (SamplingStats Double))
-> (Point m -> m (SamplingStats Double))
-> Event m (SamplingStats Double)
forall a b. (a -> b) -> a -> b
$ \Point m
p -> Point m
-> Event m (SamplingStats Double) -> m (SamplingStats Double)
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m (SamplingStats Double) -> m (SamplingStats Double))
-> Event m (SamplingStats Double) -> m (SamplingStats Double)
forall a b. (a -> b) -> a -> b
$ Ref m (SamplingStats Double) -> Event m (SamplingStats Double)
forall a. Ref m a -> Event m a
forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (Queue m sm so a -> Ref m (SamplingStats Double)
forall (m :: * -> *) sm so a.
Queue m sm so a -> Ref m (SamplingStats Double)
queueWaitTimeRef Queue m sm so a
q)
queueWaitTimeChanged :: MonadDES m => Queue m sm so a -> Signal m (SamplingStats Double)
{-# INLINABLE queueWaitTimeChanged #-}
queueWaitTimeChanged :: forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Signal m (SamplingStats Double)
queueWaitTimeChanged Queue m sm so a
q =
(() -> Event m (SamplingStats Double))
-> Signal m () -> Signal m (SamplingStats Double)
forall (m :: * -> *) a b.
MonadDES m =>
(a -> Event m b) -> Signal m a -> Signal m b
mapSignalM (Event m (SamplingStats Double)
-> () -> Event m (SamplingStats Double)
forall a b. a -> b -> a
const (Event m (SamplingStats Double)
-> () -> Event m (SamplingStats Double))
-> Event m (SamplingStats Double)
-> ()
-> Event m (SamplingStats Double)
forall a b. (a -> b) -> a -> b
$ Queue m sm so a -> Event m (SamplingStats Double)
forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Event m (SamplingStats Double)
queueWaitTime Queue m sm so a
q) (Queue m sm so a -> Signal m ()
forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Signal m ()
queueWaitTimeChanged_ Queue m sm so a
q)
queueWaitTimeChanged_ :: MonadDES m => Queue m sm so a -> Signal m ()
{-# INLINABLE queueWaitTimeChanged_ #-}
queueWaitTimeChanged_ :: forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Signal m ()
queueWaitTimeChanged_ Queue m sm so a
q =
(a -> ()) -> Signal m a -> Signal m ()
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (() -> a -> ()
forall a b. a -> b -> a
const ()) (Queue m sm so a -> Signal m a
forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Signal m a
dequeueExtracted Queue m sm so a
q)
dequeueWaitTime :: MonadDES m => Queue m sm so a -> Event m (SamplingStats Double)
{-# INLINABLE dequeueWaitTime #-}
dequeueWaitTime :: forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Event m (SamplingStats Double)
dequeueWaitTime Queue m sm so a
q =
(Point m -> m (SamplingStats Double))
-> Event m (SamplingStats Double)
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event ((Point m -> m (SamplingStats Double))
-> Event m (SamplingStats Double))
-> (Point m -> m (SamplingStats Double))
-> Event m (SamplingStats Double)
forall a b. (a -> b) -> a -> b
$ \Point m
p -> Point m
-> Event m (SamplingStats Double) -> m (SamplingStats Double)
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m (SamplingStats Double) -> m (SamplingStats Double))
-> Event m (SamplingStats Double) -> m (SamplingStats Double)
forall a b. (a -> b) -> a -> b
$ Ref m (SamplingStats Double) -> Event m (SamplingStats Double)
forall a. Ref m a -> Event m a
forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (Queue m sm so a -> Ref m (SamplingStats Double)
forall (m :: * -> *) sm so a.
Queue m sm so a -> Ref m (SamplingStats Double)
dequeueWaitTimeRef Queue m sm so a
q)
dequeueWaitTimeChanged :: MonadDES m => Queue m sm so a -> Signal m (SamplingStats Double)
{-# INLINABLE dequeueWaitTimeChanged #-}
dequeueWaitTimeChanged :: forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Signal m (SamplingStats Double)
dequeueWaitTimeChanged Queue m sm so a
q =
(() -> Event m (SamplingStats Double))
-> Signal m () -> Signal m (SamplingStats Double)
forall (m :: * -> *) a b.
MonadDES m =>
(a -> Event m b) -> Signal m a -> Signal m b
mapSignalM (Event m (SamplingStats Double)
-> () -> Event m (SamplingStats Double)
forall a b. a -> b -> a
const (Event m (SamplingStats Double)
-> () -> Event m (SamplingStats Double))
-> Event m (SamplingStats Double)
-> ()
-> Event m (SamplingStats Double)
forall a b. (a -> b) -> a -> b
$ Queue m sm so a -> Event m (SamplingStats Double)
forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Event m (SamplingStats Double)
dequeueWaitTime Queue m sm so a
q) (Queue m sm so a -> Signal m ()
forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Signal m ()
dequeueWaitTimeChanged_ Queue m sm so a
q)
dequeueWaitTimeChanged_ :: MonadDES m => Queue m sm so a -> Signal m ()
{-# INLINABLE dequeueWaitTimeChanged_ #-}
dequeueWaitTimeChanged_ :: forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Signal m ()
dequeueWaitTimeChanged_ Queue m sm so a
q =
(a -> ()) -> Signal m a -> Signal m ()
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (() -> a -> ()
forall a b. a -> b -> a
const ()) (Queue m sm so a -> Signal m a
forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Signal m a
dequeueExtracted Queue m sm so a
q)
queueRate :: MonadDES m => Queue m sm so a -> Event m Double
{-# INLINABLE queueRate #-}
queueRate :: forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Event m Double
queueRate Queue m sm so a
q =
(Point m -> m Double) -> Event m Double
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event ((Point m -> m Double) -> Event m Double)
-> (Point m -> m Double) -> Event m Double
forall a b. (a -> b) -> a -> b
$ \Point m
p ->
do TimingStats Int
x <- Point m -> Event m (TimingStats Int) -> m (TimingStats Int)
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m (TimingStats Int) -> m (TimingStats Int))
-> Event m (TimingStats Int) -> m (TimingStats Int)
forall a b. (a -> b) -> a -> b
$ Ref m (TimingStats Int) -> Event m (TimingStats Int)
forall a. Ref m a -> Event m a
forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (Queue m sm so a -> Ref m (TimingStats Int)
forall (m :: * -> *) sm so a.
Queue m sm so a -> Ref m (TimingStats Int)
queueCountStatsRef Queue m sm so a
q)
SamplingStats Double
y <- Point m
-> Event m (SamplingStats Double) -> m (SamplingStats Double)
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m (SamplingStats Double) -> m (SamplingStats Double))
-> Event m (SamplingStats Double) -> m (SamplingStats Double)
forall a b. (a -> b) -> a -> b
$ Ref m (SamplingStats Double) -> Event m (SamplingStats Double)
forall a. Ref m a -> Event m a
forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (Queue m sm so a -> Ref m (SamplingStats Double)
forall (m :: * -> *) sm so a.
Queue m sm so a -> Ref m (SamplingStats Double)
queueWaitTimeRef Queue m sm so a
q)
Double -> m Double
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (TimingStats Int -> Double
forall a. TimingData a => TimingStats a -> Double
timingStatsMean TimingStats Int
x Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/ SamplingStats Double -> Double
forall a. SamplingStats a -> Double
samplingStatsMean SamplingStats Double
y)
queueRateChanged :: MonadDES m => Queue m sm so a -> Signal m Double
{-# INLINABLE queueRateChanged #-}
queueRateChanged :: forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Signal m Double
queueRateChanged Queue m sm so a
q =
(() -> Event m Double) -> Signal m () -> Signal m Double
forall (m :: * -> *) a b.
MonadDES m =>
(a -> Event m b) -> Signal m a -> Signal m b
mapSignalM (Event m Double -> () -> Event m Double
forall a b. a -> b -> a
const (Event m Double -> () -> Event m Double)
-> Event m Double -> () -> Event m Double
forall a b. (a -> b) -> a -> b
$ Queue m sm so a -> Event m Double
forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Event m Double
queueRate Queue m sm so a
q) (Queue m sm so a -> Signal m ()
forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Signal m ()
queueRateChanged_ Queue m sm so a
q)
queueRateChanged_ :: MonadDES m => Queue m sm so a -> Signal m ()
{-# INLINABLE queueRateChanged_ #-}
queueRateChanged_ :: forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Signal m ()
queueRateChanged_ Queue m sm so a
q =
(a -> ()) -> Signal m a -> Signal m ()
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (() -> a -> ()
forall a b. a -> b -> a
const ()) (Queue m sm so a -> Signal m a
forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Signal m a
enqueueStored Queue m sm so a
q) Signal m () -> Signal m () -> Signal m ()
forall a. Semigroup a => a -> a -> a
<>
(a -> ()) -> Signal m a -> Signal m ()
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (() -> a -> ()
forall a b. a -> b -> a
const ()) (Queue m sm so a -> Signal m a
forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Signal m a
dequeueExtracted Queue m sm so a
q)
dequeue :: (MonadDES m,
DequeueStrategy m sm,
EnqueueStrategy m so)
=> Queue m sm so a
-> Process m a
{-# INLINABLE dequeue #-}
dequeue :: forall (m :: * -> *) sm so a.
(MonadDES m, DequeueStrategy m sm, EnqueueStrategy m so) =>
Queue m sm so a -> Process m a
dequeue Queue m sm so a
q =
do Double
t <- Event m Double -> Process m Double
forall a. Event m a -> Process m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
EventLift t m =>
Event m a -> t m a
liftEvent (Event m Double -> Process m Double)
-> Event m Double -> Process m Double
forall a b. (a -> b) -> a -> b
$ Queue m sm so a -> Event m Double
forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Event m Double
dequeueRequest Queue m sm so a
q
Resource m so -> Process m ()
forall (m :: * -> *) s.
(MonadDES m, EnqueueStrategy m s) =>
Resource m s -> Process m ()
requestResource (Queue m sm so a -> Resource m so
forall (m :: * -> *) sm so a. Queue m sm so a -> Resource m so
dequeueRes Queue m sm so a
q)
Event m a -> Process m a
forall a. Event m a -> Process m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
EventLift t m =>
Event m a -> t m a
liftEvent (Event m a -> Process m a) -> Event m a -> Process m a
forall a b. (a -> b) -> a -> b
$ Queue m sm so a -> Double -> Event m a
forall (m :: * -> *) sm so a.
(MonadDES m, DequeueStrategy m sm) =>
Queue m sm so a -> Double -> Event m a
dequeueExtract Queue m sm so a
q Double
t
dequeueWithOutputPriority :: (MonadDES m,
DequeueStrategy m sm,
PriorityQueueStrategy m so po)
=> Queue m sm so a
-> po
-> Process m a
{-# INLINABLE dequeueWithOutputPriority #-}
dequeueWithOutputPriority :: forall (m :: * -> *) sm so po a.
(MonadDES m, DequeueStrategy m sm,
PriorityQueueStrategy m so po) =>
Queue m sm so a -> po -> Process m a
dequeueWithOutputPriority Queue m sm so a
q po
po =
do Double
t <- Event m Double -> Process m Double
forall a. Event m a -> Process m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
EventLift t m =>
Event m a -> t m a
liftEvent (Event m Double -> Process m Double)
-> Event m Double -> Process m Double
forall a b. (a -> b) -> a -> b
$ Queue m sm so a -> Event m Double
forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Event m Double
dequeueRequest Queue m sm so a
q
Resource m so -> po -> Process m ()
forall (m :: * -> *) s p.
(MonadDES m, PriorityQueueStrategy m s p) =>
Resource m s -> p -> Process m ()
requestResourceWithPriority (Queue m sm so a -> Resource m so
forall (m :: * -> *) sm so a. Queue m sm so a -> Resource m so
dequeueRes Queue m sm so a
q) po
po
Event m a -> Process m a
forall a. Event m a -> Process m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
EventLift t m =>
Event m a -> t m a
liftEvent (Event m a -> Process m a) -> Event m a -> Process m a
forall a b. (a -> b) -> a -> b
$ Queue m sm so a -> Double -> Event m a
forall (m :: * -> *) sm so a.
(MonadDES m, DequeueStrategy m sm) =>
Queue m sm so a -> Double -> Event m a
dequeueExtract Queue m sm so a
q Double
t
tryDequeue :: (MonadDES m, DequeueStrategy m sm)
=> Queue m sm so a
-> Event m (Maybe a)
{-# INLINABLE tryDequeue #-}
tryDequeue :: forall (m :: * -> *) sm so a.
(MonadDES m, DequeueStrategy m sm) =>
Queue m sm so a -> Event m (Maybe a)
tryDequeue Queue m sm so a
q =
do Bool
x <- Resource m so -> Event m Bool
forall (m :: * -> *) s. MonadDES m => Resource m s -> Event m Bool
tryRequestResourceWithinEvent (Queue m sm so a -> Resource m so
forall (m :: * -> *) sm so a. Queue m sm so a -> Resource m so
dequeueRes Queue m sm so a
q)
if Bool
x
then do Double
t <- Queue m sm so a -> Event m Double
forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Event m Double
dequeueRequest Queue m sm so a
q
(a -> Maybe a) -> Event m a -> Event m (Maybe a)
forall a b. (a -> b) -> Event m a -> Event m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> Maybe a
forall a. a -> Maybe a
Just (Event m a -> Event m (Maybe a)) -> Event m a -> Event m (Maybe a)
forall a b. (a -> b) -> a -> b
$ Queue m sm so a -> Double -> Event m a
forall (m :: * -> *) sm so a.
(MonadDES m, DequeueStrategy m sm) =>
Queue m sm so a -> Double -> Event m a
dequeueExtract Queue m sm so a
q Double
t
else Maybe a -> Event m (Maybe a)
forall a. a -> Event m a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe a
forall a. Maybe a
Nothing
queueDelete :: (MonadDES m,
Eq a,
DeletingQueueStrategy m sm,
DequeueStrategy m so)
=> Queue m sm so a
-> a
-> Event m Bool
{-# INLINABLE queueDelete #-}
queueDelete :: forall (m :: * -> *) a sm so.
(MonadDES m, Eq a, DeletingQueueStrategy m sm,
DequeueStrategy m so) =>
Queue m sm so a -> a -> Event m Bool
queueDelete Queue m sm so a
q a
a = (Maybe a -> Bool) -> Event m (Maybe a) -> Event m Bool
forall a b. (a -> b) -> Event m a -> Event m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Maybe a -> Bool
forall a. Maybe a -> Bool
isJust (Event m (Maybe a) -> Event m Bool)
-> Event m (Maybe a) -> Event m Bool
forall a b. (a -> b) -> a -> b
$ Queue m sm so a -> (a -> Bool) -> Event m (Maybe a)
forall (m :: * -> *) sm so a.
(MonadDES m, DeletingQueueStrategy m sm, DequeueStrategy m so) =>
Queue m sm so a -> (a -> Bool) -> Event m (Maybe a)
queueDeleteBy Queue m sm so a
q (a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a
a)
queueDelete_ :: (MonadDES m,
Eq a,
DeletingQueueStrategy m sm,
DequeueStrategy m so)
=> Queue m sm so a
-> a
-> Event m ()
{-# INLINABLE queueDelete_ #-}
queueDelete_ :: forall (m :: * -> *) a sm so.
(MonadDES m, Eq a, DeletingQueueStrategy m sm,
DequeueStrategy m so) =>
Queue m sm so a -> a -> Event m ()
queueDelete_ Queue m sm so a
q a
a = (Maybe a -> ()) -> Event m (Maybe a) -> Event m ()
forall a b. (a -> b) -> Event m a -> Event m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (() -> Maybe a -> ()
forall a b. a -> b -> a
const ()) (Event m (Maybe a) -> Event m ())
-> Event m (Maybe a) -> Event m ()
forall a b. (a -> b) -> a -> b
$ Queue m sm so a -> (a -> Bool) -> Event m (Maybe a)
forall (m :: * -> *) sm so a.
(MonadDES m, DeletingQueueStrategy m sm, DequeueStrategy m so) =>
Queue m sm so a -> (a -> Bool) -> Event m (Maybe a)
queueDeleteBy Queue m sm so a
q (a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a
a)
queueDeleteBy :: (MonadDES m,
DeletingQueueStrategy m sm,
DequeueStrategy m so)
=> Queue m sm so a
-> (a -> Bool)
-> Event m (Maybe a)
{-# INLINABLE queueDeleteBy #-}
queueDeleteBy :: forall (m :: * -> *) sm so a.
(MonadDES m, DeletingQueueStrategy m sm, DequeueStrategy m so) =>
Queue m sm so a -> (a -> Bool) -> Event m (Maybe a)
queueDeleteBy Queue m sm so a
q a -> Bool
pred =
do Bool
x <- Resource m so -> Event m Bool
forall (m :: * -> *) s. MonadDES m => Resource m s -> Event m Bool
tryRequestResourceWithinEvent (Queue m sm so a -> Resource m so
forall (m :: * -> *) sm so a. Queue m sm so a -> Resource m so
dequeueRes Queue m sm so a
q)
if Bool
x
then do Maybe (QueueItem a)
i <- StrategyQueue m sm (QueueItem a)
-> (QueueItem a -> Bool) -> Event m (Maybe (QueueItem a))
forall a. StrategyQueue m sm a -> (a -> Bool) -> Event m (Maybe a)
forall (m :: * -> *) s a.
DeletingQueueStrategy m s =>
StrategyQueue m s a -> (a -> Bool) -> Event m (Maybe a)
strategyQueueDeleteBy (Queue m sm so a -> StrategyQueue m sm (QueueItem a)
forall (m :: * -> *) sm so a.
Queue m sm so a -> StrategyQueue m sm (QueueItem a)
queueStore Queue m sm so a
q) (a -> Bool
pred (a -> Bool) -> (QueueItem a -> a) -> QueueItem a -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. QueueItem a -> a
forall a. QueueItem a -> a
itemValue)
case Maybe (QueueItem a)
i of
Maybe (QueueItem a)
Nothing ->
do Resource m so -> Event m ()
forall (m :: * -> *) s.
(MonadDES m, DequeueStrategy m s) =>
Resource m s -> Event m ()
releaseResourceWithinEvent (Queue m sm so a -> Resource m so
forall (m :: * -> *) sm so a. Queue m sm so a -> Resource m so
dequeueRes Queue m sm so a
q)
Maybe a -> Event m (Maybe a)
forall a. a -> Event m a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe a
forall a. Maybe a
Nothing
Just QueueItem a
i ->
do Double
t <- Queue m sm so a -> Event m Double
forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Event m Double
dequeueRequest Queue m sm so a
q
(a -> Maybe a) -> Event m a -> Event m (Maybe a)
forall a b. (a -> b) -> Event m a -> Event m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> Maybe a
forall a. a -> Maybe a
Just (Event m a -> Event m (Maybe a)) -> Event m a -> Event m (Maybe a)
forall a b. (a -> b) -> a -> b
$ Queue m sm so a -> Double -> QueueItem a -> Event m a
forall (m :: * -> *) sm so a.
(MonadDES m, DequeueStrategy m sm) =>
Queue m sm so a -> Double -> QueueItem a -> Event m a
dequeuePostExtract Queue m sm so a
q Double
t QueueItem a
i
else Maybe a -> Event m (Maybe a)
forall a. a -> Event m a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe a
forall a. Maybe a
Nothing
queueDeleteBy_ :: (MonadDES m,
DeletingQueueStrategy m sm,
DequeueStrategy m so)
=> Queue m sm so a
-> (a -> Bool)
-> Event m ()
{-# INLINABLE queueDeleteBy_ #-}
queueDeleteBy_ :: forall (m :: * -> *) sm so a.
(MonadDES m, DeletingQueueStrategy m sm, DequeueStrategy m so) =>
Queue m sm so a -> (a -> Bool) -> Event m ()
queueDeleteBy_ Queue m sm so a
q a -> Bool
pred = (Maybe a -> ()) -> Event m (Maybe a) -> Event m ()
forall a b. (a -> b) -> Event m a -> Event m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (() -> Maybe a -> ()
forall a b. a -> b -> a
const ()) (Event m (Maybe a) -> Event m ())
-> Event m (Maybe a) -> Event m ()
forall a b. (a -> b) -> a -> b
$ Queue m sm so a -> (a -> Bool) -> Event m (Maybe a)
forall (m :: * -> *) sm so a.
(MonadDES m, DeletingQueueStrategy m sm, DequeueStrategy m so) =>
Queue m sm so a -> (a -> Bool) -> Event m (Maybe a)
queueDeleteBy Queue m sm so a
q a -> Bool
pred
queueContains :: (MonadDES m,
Eq a,
DeletingQueueStrategy m sm)
=> Queue m sm so a
-> a
-> Event m Bool
{-# INLINABLE queueContains #-}
queueContains :: forall (m :: * -> *) a sm so.
(MonadDES m, Eq a, DeletingQueueStrategy m sm) =>
Queue m sm so a -> a -> Event m Bool
queueContains Queue m sm so a
q a
a = (Maybe a -> Bool) -> Event m (Maybe a) -> Event m Bool
forall a b. (a -> b) -> Event m a -> Event m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Maybe a -> Bool
forall a. Maybe a -> Bool
isJust (Event m (Maybe a) -> Event m Bool)
-> Event m (Maybe a) -> Event m Bool
forall a b. (a -> b) -> a -> b
$ Queue m sm so a -> (a -> Bool) -> Event m (Maybe a)
forall (m :: * -> *) sm so a.
(MonadDES m, DeletingQueueStrategy m sm) =>
Queue m sm so a -> (a -> Bool) -> Event m (Maybe a)
queueContainsBy Queue m sm so a
q (a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a
a)
queueContainsBy :: (MonadDES m,
DeletingQueueStrategy m sm)
=> Queue m sm so a
-> (a -> Bool)
-> Event m (Maybe a)
{-# INLINABLE queueContainsBy #-}
queueContainsBy :: forall (m :: * -> *) sm so a.
(MonadDES m, DeletingQueueStrategy m sm) =>
Queue m sm so a -> (a -> Bool) -> Event m (Maybe a)
queueContainsBy Queue m sm so a
q a -> Bool
pred =
do Maybe (QueueItem a)
x <- StrategyQueue m sm (QueueItem a)
-> (QueueItem a -> Bool) -> Event m (Maybe (QueueItem a))
forall a. StrategyQueue m sm a -> (a -> Bool) -> Event m (Maybe a)
forall (m :: * -> *) s a.
DeletingQueueStrategy m s =>
StrategyQueue m s a -> (a -> Bool) -> Event m (Maybe a)
strategyQueueContainsBy (Queue m sm so a -> StrategyQueue m sm (QueueItem a)
forall (m :: * -> *) sm so a.
Queue m sm so a -> StrategyQueue m sm (QueueItem a)
queueStore Queue m sm so a
q) (a -> Bool
pred (a -> Bool) -> (QueueItem a -> a) -> QueueItem a -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. QueueItem a -> a
forall a. QueueItem a -> a
itemValue)
case Maybe (QueueItem a)
x of
Maybe (QueueItem a)
Nothing -> Maybe a -> Event m (Maybe a)
forall a. a -> Event m a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe a
forall a. Maybe a
Nothing
Just QueueItem a
i -> Maybe a -> Event m (Maybe a)
forall a. a -> Event m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe a -> Event m (Maybe a)) -> Maybe a -> Event m (Maybe a)
forall a b. (a -> b) -> a -> b
$ a -> Maybe a
forall a. a -> Maybe a
Just (QueueItem a -> a
forall a. QueueItem a -> a
itemValue QueueItem a
i)
clearQueue :: (MonadDES m,
DequeueStrategy m sm)
=> Queue m sm so a
-> Event m ()
{-# INLINABLE clearQueue #-}
clearQueue :: forall (m :: * -> *) sm so a.
(MonadDES m, DequeueStrategy m sm) =>
Queue m sm so a -> Event m ()
clearQueue Queue m sm so a
q =
do Maybe a
x <- Queue m sm so a -> Event m (Maybe a)
forall (m :: * -> *) sm so a.
(MonadDES m, DequeueStrategy m sm) =>
Queue m sm so a -> Event m (Maybe a)
tryDequeue Queue m sm so a
q
case Maybe a
x of
Maybe a
Nothing -> () -> Event m ()
forall a. a -> Event m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
Just a
a -> Queue m sm so a -> Event m ()
forall (m :: * -> *) sm so a.
(MonadDES m, DequeueStrategy m sm) =>
Queue m sm so a -> Event m ()
clearQueue Queue m sm so a
q
enqueue :: (MonadDES m,
EnqueueStrategy m sm,
DequeueStrategy m so)
=> Queue m sm so a
-> a
-> Event m ()
{-# INLINABLE enqueue #-}
enqueue :: forall (m :: * -> *) sm so a.
(MonadDES m, EnqueueStrategy m sm, DequeueStrategy m so) =>
Queue m sm so a -> a -> Event m ()
enqueue = Queue m sm so a -> a -> Event m ()
forall (m :: * -> *) sm so a.
(MonadDES m, EnqueueStrategy m sm, DequeueStrategy m so) =>
Queue m sm so a -> a -> Event m ()
enqueueStore
enqueueWithStoringPriority :: (MonadDES m,
PriorityQueueStrategy m sm pm,
DequeueStrategy m so)
=> Queue m sm so a
-> pm
-> a
-> Event m ()
{-# INLINABLE enqueueWithStoringPriority #-}
enqueueWithStoringPriority :: forall (m :: * -> *) sm pm so a.
(MonadDES m, PriorityQueueStrategy m sm pm,
DequeueStrategy m so) =>
Queue m sm so a -> pm -> a -> Event m ()
enqueueWithStoringPriority = Queue m sm so a -> pm -> a -> Event m ()
forall (m :: * -> *) sm pm so a.
(MonadDES m, PriorityQueueStrategy m sm pm,
DequeueStrategy m so) =>
Queue m sm so a -> pm -> a -> Event m ()
enqueueStoreWithPriority
enqueueStored :: MonadDES m => Queue m sm so a -> Signal m a
{-# INLINABLE enqueueStored #-}
enqueueStored :: forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Signal m a
enqueueStored Queue m sm so a
q = SignalSource m a -> Signal m a
forall (m :: * -> *) a. SignalSource m a -> Signal m a
publishSignal (Queue m sm so a -> SignalSource m a
forall (m :: * -> *) sm so a. Queue m sm so a -> SignalSource m a
enqueueStoredSource Queue m sm so a
q)
dequeueRequested :: MonadDES m => Queue m sm so a -> Signal m ()
{-# INLINABLE dequeueRequested #-}
dequeueRequested :: forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Signal m ()
dequeueRequested Queue m sm so a
q = SignalSource m () -> Signal m ()
forall (m :: * -> *) a. SignalSource m a -> Signal m a
publishSignal (Queue m sm so a -> SignalSource m ()
forall (m :: * -> *) sm so a. Queue m sm so a -> SignalSource m ()
dequeueRequestedSource Queue m sm so a
q)
dequeueExtracted :: MonadDES m => Queue m sm so a -> Signal m a
{-# INLINABLE dequeueExtracted #-}
Queue m sm so a
q = SignalSource m a -> Signal m a
forall (m :: * -> *) a. SignalSource m a -> Signal m a
publishSignal (Queue m sm so a -> SignalSource m a
forall (m :: * -> *) sm so a. Queue m sm so a -> SignalSource m a
dequeueExtractedSource Queue m sm so a
q)
enqueueStore :: (MonadDES m,
EnqueueStrategy m sm,
DequeueStrategy m so)
=> Queue m sm so a
-> a
-> Event m ()
{-# INLINE enqueueStore #-}
enqueueStore :: forall (m :: * -> *) sm so a.
(MonadDES m, EnqueueStrategy m sm, DequeueStrategy m so) =>
Queue m sm so a -> a -> Event m ()
enqueueStore Queue m sm so a
q a
a =
(Point m -> m ()) -> Event m ()
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event ((Point m -> m ()) -> Event m ())
-> (Point m -> m ()) -> Event m ()
forall a b. (a -> b) -> a -> b
$ \Point m
p ->
do let i :: QueueItem a
i = QueueItem { itemValue :: a
itemValue = a
a,
itemStoringTime :: Double
itemStoringTime = Point m -> Double
forall (m :: * -> *). Point m -> Double
pointTime Point m
p }
Point m -> Event m () -> m ()
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m () -> m ()) -> Event m () -> m ()
forall a b. (a -> b) -> a -> b
$
StrategyQueue m sm (QueueItem a) -> QueueItem a -> Event m ()
forall a. StrategyQueue m sm a -> a -> Event m ()
forall (m :: * -> *) s a.
EnqueueStrategy m s =>
StrategyQueue m s a -> a -> Event m ()
strategyEnqueue (Queue m sm so a -> StrategyQueue m sm (QueueItem a)
forall (m :: * -> *) sm so a.
Queue m sm so a -> StrategyQueue m sm (QueueItem a)
queueStore Queue m sm so a
q) QueueItem a
i
Int
c <- Point m -> Event m Int -> m Int
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m Int -> m Int) -> Event m Int -> m Int
forall a b. (a -> b) -> a -> b
$
Ref m Int -> Event m Int
forall a. Ref m a -> Event m a
forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (Queue m sm so a -> Ref m Int
forall (m :: * -> *) sm so a. Queue m sm so a -> Ref m Int
queueCountRef Queue m sm so a
q)
let c' :: Int
c' = Int
c Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1
t :: Double
t = Point m -> Double
forall (m :: * -> *). Point m -> Double
pointTime Point m
p
Int
c' Int -> m () -> m ()
forall a b. a -> b -> b
`seq` Point m -> Event m () -> m ()
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m () -> m ()) -> Event m () -> m ()
forall a b. (a -> b) -> a -> b
$
Ref m Int -> Int -> Event m ()
forall a. Ref m a -> a -> Event m ()
forall (m :: * -> *) a. MonadRef m => Ref m a -> a -> Event m ()
writeRef (Queue m sm so a -> Ref m Int
forall (m :: * -> *) sm so a. Queue m sm so a -> Ref m Int
queueCountRef Queue m sm so a
q) Int
c'
Point m -> Event m () -> m ()
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m () -> m ()) -> Event m () -> m ()
forall a b. (a -> b) -> a -> b
$
Ref m (TimingStats Int)
-> (TimingStats Int -> TimingStats Int) -> Event m ()
forall a. Ref m a -> (a -> a) -> Event m ()
forall (m :: * -> *) a.
MonadRef m =>
Ref m a -> (a -> a) -> Event m ()
modifyRef (Queue m sm so a -> Ref m (TimingStats Int)
forall (m :: * -> *) sm so a.
Queue m sm so a -> Ref m (TimingStats Int)
queueCountStatsRef Queue m sm so a
q) (Double -> Int -> TimingStats Int -> TimingStats Int
forall a.
TimingData a =>
Double -> a -> TimingStats a -> TimingStats a
addTimingStats Double
t Int
c')
Point m -> Event m () -> m ()
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m () -> m ()) -> Event m () -> m ()
forall a b. (a -> b) -> a -> b
$
Ref m Int -> (Int -> Int) -> Event m ()
forall a. Ref m a -> (a -> a) -> Event m ()
forall (m :: * -> *) a.
MonadRef m =>
Ref m a -> (a -> a) -> Event m ()
modifyRef (Queue m sm so a -> Ref m Int
forall (m :: * -> *) sm so a. Queue m sm so a -> Ref m Int
enqueueStoreCountRef Queue m sm so a
q) (Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1)
Point m -> Event m () -> m ()
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m () -> m ()) -> Event m () -> m ()
forall a b. (a -> b) -> a -> b
$
Resource m so -> Event m ()
forall (m :: * -> *) s.
(MonadDES m, DequeueStrategy m s) =>
Resource m s -> Event m ()
releaseResourceWithinEvent (Queue m sm so a -> Resource m so
forall (m :: * -> *) sm so a. Queue m sm so a -> Resource m so
dequeueRes Queue m sm so a
q)
Point m -> Event m () -> m ()
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m () -> m ()) -> Event m () -> m ()
forall a b. (a -> b) -> a -> b
$
SignalSource m a -> a -> Event m ()
forall (m :: * -> *) a. SignalSource m a -> a -> Event m ()
triggerSignal (Queue m sm so a -> SignalSource m a
forall (m :: * -> *) sm so a. Queue m sm so a -> SignalSource m a
enqueueStoredSource Queue m sm so a
q) (QueueItem a -> a
forall a. QueueItem a -> a
itemValue QueueItem a
i)
enqueueStoreWithPriority :: (MonadDES m,
PriorityQueueStrategy m sm pm,
DequeueStrategy m so)
=> Queue m sm so a
-> pm
-> a
-> Event m ()
{-# INLINE enqueueStoreWithPriority #-}
enqueueStoreWithPriority :: forall (m :: * -> *) sm pm so a.
(MonadDES m, PriorityQueueStrategy m sm pm,
DequeueStrategy m so) =>
Queue m sm so a -> pm -> a -> Event m ()
enqueueStoreWithPriority Queue m sm so a
q pm
pm a
a =
(Point m -> m ()) -> Event m ()
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event ((Point m -> m ()) -> Event m ())
-> (Point m -> m ()) -> Event m ()
forall a b. (a -> b) -> a -> b
$ \Point m
p ->
do let i :: QueueItem a
i = QueueItem { itemValue :: a
itemValue = a
a,
itemStoringTime :: Double
itemStoringTime = Point m -> Double
forall (m :: * -> *). Point m -> Double
pointTime Point m
p }
Point m -> Event m () -> m ()
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m () -> m ()) -> Event m () -> m ()
forall a b. (a -> b) -> a -> b
$
StrategyQueue m sm (QueueItem a) -> pm -> QueueItem a -> Event m ()
forall a. StrategyQueue m sm a -> pm -> a -> Event m ()
forall (m :: * -> *) s p a.
PriorityQueueStrategy m s p =>
StrategyQueue m s a -> p -> a -> Event m ()
strategyEnqueueWithPriority (Queue m sm so a -> StrategyQueue m sm (QueueItem a)
forall (m :: * -> *) sm so a.
Queue m sm so a -> StrategyQueue m sm (QueueItem a)
queueStore Queue m sm so a
q) pm
pm QueueItem a
i
Int
c <- Point m -> Event m Int -> m Int
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m Int -> m Int) -> Event m Int -> m Int
forall a b. (a -> b) -> a -> b
$
Ref m Int -> Event m Int
forall a. Ref m a -> Event m a
forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (Queue m sm so a -> Ref m Int
forall (m :: * -> *) sm so a. Queue m sm so a -> Ref m Int
queueCountRef Queue m sm so a
q)
let c' :: Int
c' = Int
c Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1
t :: Double
t = Point m -> Double
forall (m :: * -> *). Point m -> Double
pointTime Point m
p
Int
c' Int -> m () -> m ()
forall a b. a -> b -> b
`seq` Point m -> Event m () -> m ()
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m () -> m ()) -> Event m () -> m ()
forall a b. (a -> b) -> a -> b
$
Ref m Int -> Int -> Event m ()
forall a. Ref m a -> a -> Event m ()
forall (m :: * -> *) a. MonadRef m => Ref m a -> a -> Event m ()
writeRef (Queue m sm so a -> Ref m Int
forall (m :: * -> *) sm so a. Queue m sm so a -> Ref m Int
queueCountRef Queue m sm so a
q) Int
c'
Point m -> Event m () -> m ()
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m () -> m ()) -> Event m () -> m ()
forall a b. (a -> b) -> a -> b
$
Ref m (TimingStats Int)
-> (TimingStats Int -> TimingStats Int) -> Event m ()
forall a. Ref m a -> (a -> a) -> Event m ()
forall (m :: * -> *) a.
MonadRef m =>
Ref m a -> (a -> a) -> Event m ()
modifyRef (Queue m sm so a -> Ref m (TimingStats Int)
forall (m :: * -> *) sm so a.
Queue m sm so a -> Ref m (TimingStats Int)
queueCountStatsRef Queue m sm so a
q) (Double -> Int -> TimingStats Int -> TimingStats Int
forall a.
TimingData a =>
Double -> a -> TimingStats a -> TimingStats a
addTimingStats Double
t Int
c')
Point m -> Event m () -> m ()
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m () -> m ()) -> Event m () -> m ()
forall a b. (a -> b) -> a -> b
$
Ref m Int -> (Int -> Int) -> Event m ()
forall a. Ref m a -> (a -> a) -> Event m ()
forall (m :: * -> *) a.
MonadRef m =>
Ref m a -> (a -> a) -> Event m ()
modifyRef (Queue m sm so a -> Ref m Int
forall (m :: * -> *) sm so a. Queue m sm so a -> Ref m Int
enqueueStoreCountRef Queue m sm so a
q) (Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1)
Point m -> Event m () -> m ()
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m () -> m ()) -> Event m () -> m ()
forall a b. (a -> b) -> a -> b
$
Resource m so -> Event m ()
forall (m :: * -> *) s.
(MonadDES m, DequeueStrategy m s) =>
Resource m s -> Event m ()
releaseResourceWithinEvent (Queue m sm so a -> Resource m so
forall (m :: * -> *) sm so a. Queue m sm so a -> Resource m so
dequeueRes Queue m sm so a
q)
Point m -> Event m () -> m ()
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m () -> m ()) -> Event m () -> m ()
forall a b. (a -> b) -> a -> b
$
SignalSource m a -> a -> Event m ()
forall (m :: * -> *) a. SignalSource m a -> a -> Event m ()
triggerSignal (Queue m sm so a -> SignalSource m a
forall (m :: * -> *) sm so a. Queue m sm so a -> SignalSource m a
enqueueStoredSource Queue m sm so a
q) (QueueItem a -> a
forall a. QueueItem a -> a
itemValue QueueItem a
i)
dequeueRequest :: MonadDES m
=> Queue m sm so a
-> Event m Double
{-# INLINE dequeueRequest #-}
dequeueRequest :: forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Event m Double
dequeueRequest Queue m sm so a
q =
(Point m -> m Double) -> Event m Double
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event ((Point m -> m Double) -> Event m Double)
-> (Point m -> m Double) -> Event m Double
forall a b. (a -> b) -> a -> b
$ \Point m
p ->
do Point m -> Event m () -> m ()
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m () -> m ()) -> Event m () -> m ()
forall a b. (a -> b) -> a -> b
$
Ref m Int -> (Int -> Int) -> Event m ()
forall a. Ref m a -> (a -> a) -> Event m ()
forall (m :: * -> *) a.
MonadRef m =>
Ref m a -> (a -> a) -> Event m ()
modifyRef (Queue m sm so a -> Ref m Int
forall (m :: * -> *) sm so a. Queue m sm so a -> Ref m Int
dequeueCountRef Queue m sm so a
q) (Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1)
Point m -> Event m () -> m ()
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m () -> m ()) -> Event m () -> m ()
forall a b. (a -> b) -> a -> b
$
SignalSource m () -> () -> Event m ()
forall (m :: * -> *) a. SignalSource m a -> a -> Event m ()
triggerSignal (Queue m sm so a -> SignalSource m ()
forall (m :: * -> *) sm so a. Queue m sm so a -> SignalSource m ()
dequeueRequestedSource Queue m sm so a
q) ()
Double -> m Double
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Double -> m Double) -> Double -> m Double
forall a b. (a -> b) -> a -> b
$ Point m -> Double
forall (m :: * -> *). Point m -> Double
pointTime Point m
p
dequeueExtract :: (MonadDES m, DequeueStrategy m sm)
=> Queue m sm so a
-> Double
-> Event m a
{-# INLINE dequeueExtract #-}
Queue m sm so a
q Double
t' =
(Point m -> m a) -> Event m a
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event ((Point m -> m a) -> Event m a) -> (Point m -> m a) -> Event m a
forall a b. (a -> b) -> a -> b
$ \Point m
p ->
do QueueItem a
i <- Point m -> Event m (QueueItem a) -> m (QueueItem a)
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m (QueueItem a) -> m (QueueItem a))
-> Event m (QueueItem a) -> m (QueueItem a)
forall a b. (a -> b) -> a -> b
$
StrategyQueue m sm (QueueItem a) -> Event m (QueueItem a)
forall a. StrategyQueue m sm a -> Event m a
forall (m :: * -> *) s a.
DequeueStrategy m s =>
StrategyQueue m s a -> Event m a
strategyDequeue (Queue m sm so a -> StrategyQueue m sm (QueueItem a)
forall (m :: * -> *) sm so a.
Queue m sm so a -> StrategyQueue m sm (QueueItem a)
queueStore Queue m sm so a
q)
Point m -> Event m a -> m a
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m a -> m a) -> Event m a -> m a
forall a b. (a -> b) -> a -> b
$
Queue m sm so a -> Double -> QueueItem a -> Event m a
forall (m :: * -> *) sm so a.
(MonadDES m, DequeueStrategy m sm) =>
Queue m sm so a -> Double -> QueueItem a -> Event m a
dequeuePostExtract Queue m sm so a
q Double
t' QueueItem a
i
dequeuePostExtract :: (MonadDES m,
DequeueStrategy m sm)
=> Queue m sm so a
-> Double
-> QueueItem a
-> Event m a
{-# INLINE dequeuePostExtract #-}
Queue m sm so a
q Double
t' QueueItem a
i =
(Point m -> m a) -> Event m a
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event ((Point m -> m a) -> Event m a) -> (Point m -> m a) -> Event m a
forall a b. (a -> b) -> a -> b
$ \Point m
p ->
do Int
c <- Point m -> Event m Int -> m Int
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m Int -> m Int) -> Event m Int -> m Int
forall a b. (a -> b) -> a -> b
$
Ref m Int -> Event m Int
forall a. Ref m a -> Event m a
forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (Queue m sm so a -> Ref m Int
forall (m :: * -> *) sm so a. Queue m sm so a -> Ref m Int
queueCountRef Queue m sm so a
q)
let c' :: Int
c' = Int
c Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1
t :: Double
t = Point m -> Double
forall (m :: * -> *). Point m -> Double
pointTime Point m
p
Int
c' Int -> m () -> m ()
forall a b. a -> b -> b
`seq` Point m -> Event m () -> m ()
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m () -> m ()) -> Event m () -> m ()
forall a b. (a -> b) -> a -> b
$
Ref m Int -> Int -> Event m ()
forall a. Ref m a -> a -> Event m ()
forall (m :: * -> *) a. MonadRef m => Ref m a -> a -> Event m ()
writeRef (Queue m sm so a -> Ref m Int
forall (m :: * -> *) sm so a. Queue m sm so a -> Ref m Int
queueCountRef Queue m sm so a
q) Int
c'
Point m -> Event m () -> m ()
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m () -> m ()) -> Event m () -> m ()
forall a b. (a -> b) -> a -> b
$
Ref m (TimingStats Int)
-> (TimingStats Int -> TimingStats Int) -> Event m ()
forall a. Ref m a -> (a -> a) -> Event m ()
forall (m :: * -> *) a.
MonadRef m =>
Ref m a -> (a -> a) -> Event m ()
modifyRef (Queue m sm so a -> Ref m (TimingStats Int)
forall (m :: * -> *) sm so a.
Queue m sm so a -> Ref m (TimingStats Int)
queueCountStatsRef Queue m sm so a
q) (Double -> Int -> TimingStats Int -> TimingStats Int
forall a.
TimingData a =>
Double -> a -> TimingStats a -> TimingStats a
addTimingStats Double
t Int
c')
Point m -> Event m () -> m ()
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m () -> m ()) -> Event m () -> m ()
forall a b. (a -> b) -> a -> b
$
Ref m Int -> (Int -> Int) -> Event m ()
forall a. Ref m a -> (a -> a) -> Event m ()
forall (m :: * -> *) a.
MonadRef m =>
Ref m a -> (a -> a) -> Event m ()
modifyRef (Queue m sm so a -> Ref m Int
forall (m :: * -> *) sm so a. Queue m sm so a -> Ref m Int
dequeueExtractCountRef Queue m sm so a
q) (Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1)
Point m -> Event m () -> m ()
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m () -> m ()) -> Event m () -> m ()
forall a b. (a -> b) -> a -> b
$
Queue m sm so a -> Double -> QueueItem a -> Event m ()
forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Double -> QueueItem a -> Event m ()
dequeueStat Queue m sm so a
q Double
t' QueueItem a
i
Point m -> Event m () -> m ()
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m () -> m ()) -> Event m () -> m ()
forall a b. (a -> b) -> a -> b
$
SignalSource m a -> a -> Event m ()
forall (m :: * -> *) a. SignalSource m a -> a -> Event m ()
triggerSignal (Queue m sm so a -> SignalSource m a
forall (m :: * -> *) sm so a. Queue m sm so a -> SignalSource m a
dequeueExtractedSource Queue m sm so a
q) (QueueItem a -> a
forall a. QueueItem a -> a
itemValue QueueItem a
i)
a -> m a
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (a -> m a) -> a -> m a
forall a b. (a -> b) -> a -> b
$ QueueItem a -> a
forall a. QueueItem a -> a
itemValue QueueItem a
i
dequeueStat :: MonadDES m
=> Queue m sm so a
-> Double
-> QueueItem a
-> Event m ()
{-# INLINE dequeueStat #-}
dequeueStat :: forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Double -> QueueItem a -> Event m ()
dequeueStat Queue m sm so a
q Double
t' QueueItem a
i =
(Point m -> m ()) -> Event m ()
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event ((Point m -> m ()) -> Event m ())
-> (Point m -> m ()) -> Event m ()
forall a b. (a -> b) -> a -> b
$ \Point m
p ->
do let t1 :: Double
t1 = QueueItem a -> Double
forall a. QueueItem a -> Double
itemStoringTime QueueItem a
i
t :: Double
t = Point m -> Double
forall (m :: * -> *). Point m -> Double
pointTime Point m
p
Point m -> Event m () -> m ()
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m () -> m ()) -> Event m () -> m ()
forall a b. (a -> b) -> a -> b
$
Ref m (SamplingStats Double)
-> (SamplingStats Double -> SamplingStats Double) -> Event m ()
forall a. Ref m a -> (a -> a) -> Event m ()
forall (m :: * -> *) a.
MonadRef m =>
Ref m a -> (a -> a) -> Event m ()
modifyRef (Queue m sm so a -> Ref m (SamplingStats Double)
forall (m :: * -> *) sm so a.
Queue m sm so a -> Ref m (SamplingStats Double)
dequeueWaitTimeRef Queue m sm so a
q) ((SamplingStats Double -> SamplingStats Double) -> Event m ())
-> (SamplingStats Double -> SamplingStats Double) -> Event m ()
forall a b. (a -> b) -> a -> b
$
Double -> SamplingStats Double -> SamplingStats Double
forall a. SamplingData a => a -> SamplingStats a -> SamplingStats a
addSamplingStats (Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
t')
Point m -> Event m () -> m ()
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m () -> m ()) -> Event m () -> m ()
forall a b. (a -> b) -> a -> b
$
Ref m (SamplingStats Double)
-> (SamplingStats Double -> SamplingStats Double) -> Event m ()
forall a. Ref m a -> (a -> a) -> Event m ()
forall (m :: * -> *) a.
MonadRef m =>
Ref m a -> (a -> a) -> Event m ()
modifyRef (Queue m sm so a -> Ref m (SamplingStats Double)
forall (m :: * -> *) sm so a.
Queue m sm so a -> Ref m (SamplingStats Double)
queueWaitTimeRef Queue m sm so a
q) ((SamplingStats Double -> SamplingStats Double) -> Event m ())
-> (SamplingStats Double -> SamplingStats Double) -> Event m ()
forall a b. (a -> b) -> a -> b
$
Double -> SamplingStats Double -> SamplingStats Double
forall a. SamplingData a => a -> SamplingStats a -> SamplingStats a
addSamplingStats (Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
t1)
queueChanged_ :: MonadDES m => Queue m sm so a -> Signal m ()
{-# INLINABLE queueChanged_ #-}
queueChanged_ :: forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Signal m ()
queueChanged_ Queue m sm so a
q =
(a -> ()) -> Signal m a -> Signal m ()
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (() -> a -> ()
forall a b. a -> b -> a
const ()) (Queue m sm so a -> Signal m a
forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Signal m a
enqueueStored Queue m sm so a
q) Signal m () -> Signal m () -> Signal m ()
forall a. Semigroup a => a -> a -> a
<>
Queue m sm so a -> Signal m ()
forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Signal m ()
dequeueRequested Queue m sm so a
q Signal m () -> Signal m () -> Signal m ()
forall a. Semigroup a => a -> a -> a
<>
(a -> ()) -> Signal m a -> Signal m ()
forall (m :: * -> *) a b.
MonadDES m =>
(a -> b) -> Signal m a -> Signal m b
mapSignal (() -> a -> ()
forall a b. a -> b -> a
const ()) (Queue m sm so a -> Signal m a
forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Signal m a
dequeueExtracted Queue m sm so a
q)
queueSummary :: (MonadDES m, Show sm, Show so) => Queue m sm so a -> Int -> Event m ShowS
{-# INLINABLE queueSummary #-}
queueSummary :: forall (m :: * -> *) sm so a.
(MonadDES m, Show sm, Show so) =>
Queue m sm so a -> Int -> Event m ShowS
queueSummary Queue m sm so a
q Int
indent =
do let sm :: sm
sm = Queue m sm so a -> sm
forall (m :: * -> *) sm so a. Queue m sm so a -> sm
enqueueStoringStrategy Queue m sm so a
q
so :: so
so = Queue m sm so a -> so
forall (m :: * -> *) sm so a. Queue m sm so a -> so
dequeueStrategy Queue m sm so a
q
Bool
null <- Queue m sm so a -> Event m Bool
forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Event m Bool
queueNull Queue m sm so a
q
Int
count <- Queue m sm so a -> Event m Int
forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Event m Int
queueCount Queue m sm so a
q
TimingStats Int
countStats <- Queue m sm so a -> Event m (TimingStats Int)
forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Event m (TimingStats Int)
queueCountStats Queue m sm so a
q
Int
enqueueStoreCount <- Queue m sm so a -> Event m Int
forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Event m Int
enqueueStoreCount Queue m sm so a
q
Int
dequeueCount <- Queue m sm so a -> Event m Int
forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Event m Int
dequeueCount Queue m sm so a
q
Int
dequeueExtractCount <- Queue m sm so a -> Event m Int
forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Event m Int
dequeueExtractCount Queue m sm so a
q
Double
enqueueStoreRate <- Queue m sm so a -> Event m Double
forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Event m Double
enqueueStoreRate Queue m sm so a
q
Double
dequeueRate <- Queue m sm so a -> Event m Double
forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Event m Double
dequeueRate Queue m sm so a
q
Double
dequeueExtractRate <- Queue m sm so a -> Event m Double
forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Event m Double
dequeueExtractRate Queue m sm so a
q
SamplingStats Double
waitTime <- Queue m sm so a -> Event m (SamplingStats Double)
forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Event m (SamplingStats Double)
queueWaitTime Queue m sm so a
q
SamplingStats Double
dequeueWaitTime <- Queue m sm so a -> Event m (SamplingStats Double)
forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Event m (SamplingStats Double)
dequeueWaitTime Queue m sm so a
q
let tab :: [Char]
tab = Int -> Char -> [Char]
forall a. Int -> a -> [a]
replicate Int
indent Char
' '
ShowS -> Event m ShowS
forall a. a -> Event m a
forall (m :: * -> *) a. Monad m => a -> m a
return (ShowS -> Event m ShowS) -> ShowS -> Event m ShowS
forall a b. (a -> b) -> a -> b
$
[Char] -> ShowS
showString [Char]
tab ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"the storing (memory) strategy = " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
sm -> ShowS
forall a. Show a => a -> ShowS
shows sm
sm ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"the dequeueing (output) strategy = " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
so -> ShowS
forall a. Show a => a -> ShowS
shows so
so ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"empty? = " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Bool -> ShowS
forall a. Show a => a -> ShowS
shows Bool
null ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"the current size = " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Int -> ShowS
forall a. Show a => a -> ShowS
shows Int
count ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"the size statistics = \n\n" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
TimingStats Int -> Int -> ShowS
forall a. (Show a, TimingData a) => TimingStats a -> Int -> ShowS
timingStatsSummary TimingStats Int
countStats (Int
2 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
indent) ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n\n" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"the enqueue store count (number of the input items that were stored) = " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Int -> ShowS
forall a. Show a => a -> ShowS
shows Int
enqueueStoreCount ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"the dequeue count (number of requests for dequeueing an item) = " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Int -> ShowS
forall a. Show a => a -> ShowS
shows Int
dequeueCount ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"the dequeue extract count (number of the output items that were dequeued) = " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Int -> ShowS
forall a. Show a => a -> ShowS
shows Int
dequeueExtractCount ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"the enqueue store rate (how many input items were stored per time) = " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Double -> ShowS
forall a. Show a => a -> ShowS
shows Double
enqueueStoreRate ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"the dequeue rate (how many requests for dequeueing per time) = " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Double -> ShowS
forall a. Show a => a -> ShowS
shows Double
dequeueRate ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"the dequeue extract rate (how many output items were dequeued per time) = " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Double -> ShowS
forall a. Show a => a -> ShowS
shows Double
dequeueExtractRate ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"the wait time (when was stored -> when was dequeued) = \n\n" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
SamplingStats Double -> Int -> ShowS
forall a. Show a => SamplingStats a -> Int -> ShowS
samplingStatsSummary SamplingStats Double
waitTime (Int
2 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
indent) ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"\n\n" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
tab ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Char] -> ShowS
showString [Char]
"the dequeue wait time (when was requested for dequeueing -> when was dequeued) = \n\n" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
SamplingStats Double -> Int -> ShowS
forall a. Show a => SamplingStats a -> Int -> ShowS
samplingStatsSummary SamplingStats Double
dequeueWaitTime (Int
2 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
indent)
resetQueue :: MonadDES m => Queue m sm so a -> Event m ()
{-# INLINABLE resetQueue #-}
resetQueue :: forall (m :: * -> *) sm so a.
MonadDES m =>
Queue m sm so a -> Event m ()
resetQueue Queue m sm so a
q =
(Point m -> m ()) -> Event m ()
forall (m :: * -> *) a. (Point m -> m a) -> Event m a
Event ((Point m -> m ()) -> Event m ())
-> (Point m -> m ()) -> Event m ()
forall a b. (a -> b) -> a -> b
$ \Point m
p ->
do let t :: Double
t = Point m -> Double
forall (m :: * -> *). Point m -> Double
pointTime Point m
p
Int
queueCount <- Point m -> Event m Int -> m Int
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m Int -> m Int) -> Event m Int -> m Int
forall a b. (a -> b) -> a -> b
$ Ref m Int -> Event m Int
forall a. Ref m a -> Event m a
forall (m :: * -> *) a. MonadRef m => Ref m a -> Event m a
readRef (Queue m sm so a -> Ref m Int
forall (m :: * -> *) sm so a. Queue m sm so a -> Ref m Int
queueCountRef Queue m sm so a
q)
Point m -> Event m () -> m ()
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m () -> m ()) -> Event m () -> m ()
forall a b. (a -> b) -> a -> b
$ Ref m (TimingStats Int) -> TimingStats Int -> Event m ()
forall a. Ref m a -> a -> Event m ()
forall (m :: * -> *) a. MonadRef m => Ref m a -> a -> Event m ()
writeRef (Queue m sm so a -> Ref m (TimingStats Int)
forall (m :: * -> *) sm so a.
Queue m sm so a -> Ref m (TimingStats Int)
queueCountStatsRef Queue m sm so a
q) (TimingStats Int -> Event m ()) -> TimingStats Int -> Event m ()
forall a b. (a -> b) -> a -> b
$
Double -> Int -> TimingStats Int
forall a. TimingData a => Double -> a -> TimingStats a
returnTimingStats Double
t Int
queueCount
Point m -> Event m () -> m ()
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m () -> m ()) -> Event m () -> m ()
forall a b. (a -> b) -> a -> b
$ Ref m Int -> Int -> Event m ()
forall a. Ref m a -> a -> Event m ()
forall (m :: * -> *) a. MonadRef m => Ref m a -> a -> Event m ()
writeRef (Queue m sm so a -> Ref m Int
forall (m :: * -> *) sm so a. Queue m sm so a -> Ref m Int
enqueueStoreCountRef Queue m sm so a
q) Int
0
Point m -> Event m () -> m ()
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m () -> m ()) -> Event m () -> m ()
forall a b. (a -> b) -> a -> b
$ Ref m Int -> Int -> Event m ()
forall a. Ref m a -> a -> Event m ()
forall (m :: * -> *) a. MonadRef m => Ref m a -> a -> Event m ()
writeRef (Queue m sm so a -> Ref m Int
forall (m :: * -> *) sm so a. Queue m sm so a -> Ref m Int
dequeueCountRef Queue m sm so a
q) Int
0
Point m -> Event m () -> m ()
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m () -> m ()) -> Event m () -> m ()
forall a b. (a -> b) -> a -> b
$ Ref m Int -> Int -> Event m ()
forall a. Ref m a -> a -> Event m ()
forall (m :: * -> *) a. MonadRef m => Ref m a -> a -> Event m ()
writeRef (Queue m sm so a -> Ref m Int
forall (m :: * -> *) sm so a. Queue m sm so a -> Ref m Int
dequeueExtractCountRef Queue m sm so a
q) Int
0
Point m -> Event m () -> m ()
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m () -> m ()) -> Event m () -> m ()
forall a b. (a -> b) -> a -> b
$ Ref m (SamplingStats Double) -> SamplingStats Double -> Event m ()
forall a. Ref m a -> a -> Event m ()
forall (m :: * -> *) a. MonadRef m => Ref m a -> a -> Event m ()
writeRef (Queue m sm so a -> Ref m (SamplingStats Double)
forall (m :: * -> *) sm so a.
Queue m sm so a -> Ref m (SamplingStats Double)
queueWaitTimeRef Queue m sm so a
q) SamplingStats Double
forall a. Monoid a => a
mempty
Point m -> Event m () -> m ()
forall (m :: * -> *) a. Point m -> Event m a -> m a
invokeEvent Point m
p (Event m () -> m ()) -> Event m () -> m ()
forall a b. (a -> b) -> a -> b
$ Ref m (SamplingStats Double) -> SamplingStats Double -> Event m ()
forall a. Ref m a -> a -> Event m ()
forall (m :: * -> *) a. MonadRef m => Ref m a -> a -> Event m ()
writeRef (Queue m sm so a -> Ref m (SamplingStats Double)
forall (m :: * -> *) sm so a.
Queue m sm so a -> Ref m (SamplingStats Double)
dequeueWaitTimeRef Queue m sm so a
q) SamplingStats Double
forall a. Monoid a => a
mempty