module Simulation.Aivika.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.IORef
import Data.Monoid
import Data.Maybe
import Control.Monad
import Control.Monad.Trans
import Simulation.Aivika.Internal.Specs
import Simulation.Aivika.Internal.Simulation
import Simulation.Aivika.Internal.Dynamics
import Simulation.Aivika.Internal.Event
import Simulation.Aivika.Internal.Process
import Simulation.Aivika.Signal
import Simulation.Aivika.Resource.Base
import Simulation.Aivika.QueueStrategy
import Simulation.Aivika.Statistics
import qualified Simulation.Aivika.DoubleLinkedList as DLL
import qualified Simulation.Aivika.Vector as V
import qualified Simulation.Aivika.PriorityQueue as PQ
type FCFSQueue a = Queue FCFS FCFS FCFS a
type LCFSQueue a = Queue FCFS LCFS FCFS a
type SIROQueue a = Queue FCFS SIRO FCFS a
type PriorityQueue a = Queue FCFS StaticPriorities FCFS a
data Queue si sm so a =
Queue { forall si sm so a. Queue si sm so a -> Int
queueMaxCount :: Int,
forall si sm so a. Queue si sm so a -> si
enqueueStrategy :: si,
forall si sm so a. Queue si sm so a -> sm
enqueueStoringStrategy :: sm,
forall si sm so a. Queue si sm so a -> so
dequeueStrategy :: so,
forall si sm so a. Queue si sm so a -> Resource si
enqueueRes :: Resource si,
forall si sm so a.
Queue si sm so a -> StrategyQueue sm (QueueItem a)
queueStore :: StrategyQueue sm (QueueItem a),
forall si sm so a. Queue si sm so a -> Resource so
dequeueRes :: Resource so,
forall si sm so a. Queue si sm so a -> IORef Int
queueCountRef :: IORef Int,
forall si sm so a. Queue si sm so a -> IORef (TimingStats Int)
queueCountStatsRef :: IORef (TimingStats Int),
forall si sm so a. Queue si sm so a -> IORef Int
enqueueCountRef :: IORef Int,
forall si sm so a. Queue si sm so a -> IORef Int
enqueueLostCountRef :: IORef Int,
forall si sm so a. Queue si sm so a -> IORef Int
enqueueStoreCountRef :: IORef Int,
forall si sm so a. Queue si sm so a -> IORef Int
dequeueCountRef :: IORef Int,
:: IORef Int,
forall si sm so a. Queue si sm so a -> IORef (SamplingStats Double)
queueWaitTimeRef :: IORef (SamplingStats Double),
forall si sm so a. Queue si sm so a -> IORef (SamplingStats Double)
queueTotalWaitTimeRef :: IORef (SamplingStats Double),
forall si sm so a. Queue si sm so a -> IORef (SamplingStats Double)
enqueueWaitTimeRef :: IORef (SamplingStats Double),
forall si sm so a. Queue si sm so a -> IORef (SamplingStats Double)
dequeueWaitTimeRef :: IORef (SamplingStats Double),
forall si sm so a. Queue si sm so a -> SignalSource a
enqueueInitiatedSource :: SignalSource a,
forall si sm so a. Queue si sm so a -> SignalSource a
enqueueLostSource :: SignalSource a,
forall si sm so a. Queue si sm so a -> SignalSource a
enqueueStoredSource :: SignalSource a,
forall si sm so a. Queue si sm so a -> SignalSource ()
dequeueRequestedSource :: SignalSource (),
:: SignalSource 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 :: Int -> Event (FCFSQueue a)
newFCFSQueue :: forall a. Int -> Event (FCFSQueue a)
newFCFSQueue = forall si sm so a.
(QueueStrategy si, QueueStrategy sm, QueueStrategy so) =>
si -> sm -> so -> Int -> Event (Queue si sm so a)
newQueue FCFS
FCFS FCFS
FCFS FCFS
FCFS
newLCFSQueue :: Int -> Event (LCFSQueue a)
newLCFSQueue :: forall a. Int -> Event (LCFSQueue a)
newLCFSQueue = forall si sm so a.
(QueueStrategy si, QueueStrategy sm, QueueStrategy so) =>
si -> sm -> so -> Int -> Event (Queue si sm so a)
newQueue FCFS
FCFS LCFS
LCFS FCFS
FCFS
newSIROQueue :: Int -> Event (SIROQueue a)
newSIROQueue :: forall a. Int -> Event (SIROQueue a)
newSIROQueue = forall si sm so a.
(QueueStrategy si, QueueStrategy sm, QueueStrategy so) =>
si -> sm -> so -> Int -> Event (Queue si sm so a)
newQueue FCFS
FCFS SIRO
SIRO FCFS
FCFS
newPriorityQueue :: Int -> Event (PriorityQueue a)
newPriorityQueue :: forall a. Int -> Event (PriorityQueue a)
newPriorityQueue = forall si sm so a.
(QueueStrategy si, QueueStrategy sm, QueueStrategy so) =>
si -> sm -> so -> Int -> Event (Queue si sm so a)
newQueue FCFS
FCFS StaticPriorities
StaticPriorities FCFS
FCFS
newQueue :: (QueueStrategy si,
QueueStrategy sm,
QueueStrategy so) =>
si
-> sm
-> so
-> Int
-> Event (Queue si sm so a)
newQueue :: forall si sm so a.
(QueueStrategy si, QueueStrategy sm, QueueStrategy so) =>
si -> sm -> so -> Int -> Event (Queue si sm so a)
newQueue si
si sm
sm so
so Int
count =
do Double
t <- forall (m :: * -> *) a. DynamicsLift m => Dynamics a -> m a
liftDynamics Dynamics Double
time
IORef Int
i <- forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ forall a. a -> IO (IORef a)
newIORef Int
0
IORef (TimingStats Int)
is <- forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ forall a. a -> IO (IORef a)
newIORef forall a b. (a -> b) -> a -> b
$ forall a. TimingData a => Double -> a -> TimingStats a
returnTimingStats Double
t Int
0
IORef Int
ci <- forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ forall a. a -> IO (IORef a)
newIORef Int
0
IORef Int
cl <- forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ forall a. a -> IO (IORef a)
newIORef Int
0
IORef Int
cm <- forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ forall a. a -> IO (IORef a)
newIORef Int
0
IORef Int
cr <- forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ forall a. a -> IO (IORef a)
newIORef Int
0
IORef Int
co <- forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ forall a. a -> IO (IORef a)
newIORef Int
0
Resource si
ri <- forall (m :: * -> *) a. SimulationLift m => Simulation a -> m a
liftSimulation forall a b. (a -> b) -> a -> b
$ forall s.
QueueStrategy s =>
s -> Int -> Maybe Int -> Simulation (Resource s)
newResourceWithMaxCount si
si Int
count (forall a. a -> Maybe a
Just Int
count)
StrategyQueue sm (QueueItem a)
qm <- forall (m :: * -> *) a. SimulationLift m => Simulation a -> m a
liftSimulation forall a b. (a -> b) -> a -> b
$ forall s i. QueueStrategy s => s -> Simulation (StrategyQueue s i)
newStrategyQueue sm
sm
Resource so
ro <- forall (m :: * -> *) a. SimulationLift m => Simulation a -> m a
liftSimulation forall a b. (a -> b) -> a -> b
$ forall s.
QueueStrategy s =>
s -> Int -> Maybe Int -> Simulation (Resource s)
newResourceWithMaxCount so
so Int
0 (forall a. a -> Maybe a
Just Int
count)
IORef (SamplingStats Double)
w <- forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ forall a. a -> IO (IORef a)
newIORef forall a. Monoid a => a
mempty
IORef (SamplingStats Double)
wt <- forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ forall a. a -> IO (IORef a)
newIORef forall a. Monoid a => a
mempty
IORef (SamplingStats Double)
wi <- forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ forall a. a -> IO (IORef a)
newIORef forall a. Monoid a => a
mempty
IORef (SamplingStats Double)
wo <- forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ forall a. a -> IO (IORef a)
newIORef forall a. Monoid a => a
mempty
SignalSource a
s1 <- forall (m :: * -> *) a. SimulationLift m => Simulation a -> m a
liftSimulation forall a b. (a -> b) -> a -> b
$ forall a. Simulation (SignalSource a)
newSignalSource
SignalSource a
s2 <- forall (m :: * -> *) a. SimulationLift m => Simulation a -> m a
liftSimulation forall a b. (a -> b) -> a -> b
$ forall a. Simulation (SignalSource a)
newSignalSource
SignalSource a
s3 <- forall (m :: * -> *) a. SimulationLift m => Simulation a -> m a
liftSimulation forall a b. (a -> b) -> a -> b
$ forall a. Simulation (SignalSource a)
newSignalSource
SignalSource ()
s4 <- forall (m :: * -> *) a. SimulationLift m => Simulation a -> m a
liftSimulation forall a b. (a -> b) -> a -> b
$ forall a. Simulation (SignalSource a)
newSignalSource
SignalSource a
s5 <- forall (m :: * -> *) a. SimulationLift m => Simulation a -> m a
liftSimulation forall a b. (a -> b) -> a -> b
$ forall a. Simulation (SignalSource 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 si
enqueueRes = Resource si
ri,
queueStore :: StrategyQueue sm (QueueItem a)
queueStore = StrategyQueue sm (QueueItem a)
qm,
dequeueRes :: Resource so
dequeueRes = Resource so
ro,
queueCountRef :: IORef Int
queueCountRef = IORef Int
i,
queueCountStatsRef :: IORef (TimingStats Int)
queueCountStatsRef = IORef (TimingStats Int)
is,
enqueueCountRef :: IORef Int
enqueueCountRef = IORef Int
ci,
enqueueLostCountRef :: IORef Int
enqueueLostCountRef = IORef Int
cl,
enqueueStoreCountRef :: IORef Int
enqueueStoreCountRef = IORef Int
cm,
dequeueCountRef :: IORef Int
dequeueCountRef = IORef Int
cr,
dequeueExtractCountRef :: IORef Int
dequeueExtractCountRef = IORef Int
co,
queueWaitTimeRef :: IORef (SamplingStats Double)
queueWaitTimeRef = IORef (SamplingStats Double)
w,
queueTotalWaitTimeRef :: IORef (SamplingStats Double)
queueTotalWaitTimeRef = IORef (SamplingStats Double)
wt,
enqueueWaitTimeRef :: IORef (SamplingStats Double)
enqueueWaitTimeRef = IORef (SamplingStats Double)
wi,
dequeueWaitTimeRef :: IORef (SamplingStats Double)
dequeueWaitTimeRef = IORef (SamplingStats Double)
wo,
enqueueInitiatedSource :: SignalSource a
enqueueInitiatedSource = SignalSource a
s1,
enqueueLostSource :: SignalSource a
enqueueLostSource = SignalSource a
s2,
enqueueStoredSource :: SignalSource a
enqueueStoredSource = SignalSource a
s3,
dequeueRequestedSource :: SignalSource ()
dequeueRequestedSource = SignalSource ()
s4,
dequeueExtractedSource :: SignalSource a
dequeueExtractedSource = SignalSource a
s5 }
queueNull :: Queue si sm so a -> Event Bool
queueNull :: forall si sm so a. Queue si sm so a -> Event Bool
queueNull Queue si sm so a
q =
forall a. (Point -> IO a) -> Event a
Event forall a b. (a -> b) -> a -> b
$ \Point
p ->
do Int
n <- forall a. IORef a -> IO a
readIORef (forall si sm so a. Queue si sm so a -> IORef Int
queueCountRef Queue 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 :: Queue si sm so a -> Signal Bool
queueNullChanged :: forall si sm so a. Queue si sm so a -> Signal Bool
queueNullChanged Queue si sm so a
q =
forall a b. (a -> Event b) -> Signal a -> Signal b
mapSignalM (forall a b. a -> b -> a
const forall a b. (a -> b) -> a -> b
$ forall si sm so a. Queue si sm so a -> Event Bool
queueNull Queue si sm so a
q) (forall si sm so a. Queue si sm so a -> Signal ()
queueNullChanged_ Queue si sm so a
q)
queueNullChanged_ :: Queue si sm so a -> Signal ()
queueNullChanged_ :: forall si sm so a. Queue si sm so a -> Signal ()
queueNullChanged_ = forall si sm so a. Queue si sm so a -> Signal ()
queueCountChanged_
queueFull :: Queue si sm so a -> Event Bool
queueFull :: forall si sm so a. Queue si sm so a -> Event Bool
queueFull Queue si sm so a
q =
forall a. (Point -> IO a) -> Event a
Event forall a b. (a -> b) -> a -> b
$ \Point
p ->
do Int
n <- forall a. IORef a -> IO a
readIORef (forall si sm so a. Queue si sm so a -> IORef Int
queueCountRef Queue si sm so a
q)
forall (m :: * -> *) a. Monad m => a -> m a
return (Int
n forall a. Eq a => a -> a -> Bool
== forall si sm so a. Queue si sm so a -> Int
queueMaxCount Queue si sm so a
q)
queueFullChanged :: Queue si sm so a -> Signal Bool
queueFullChanged :: forall si sm so a. Queue si sm so a -> Signal Bool
queueFullChanged Queue si sm so a
q =
forall a b. (a -> Event b) -> Signal a -> Signal b
mapSignalM (forall a b. a -> b -> a
const forall a b. (a -> b) -> a -> b
$ forall si sm so a. Queue si sm so a -> Event Bool
queueFull Queue si sm so a
q) (forall si sm so a. Queue si sm so a -> Signal ()
queueFullChanged_ Queue si sm so a
q)
queueFullChanged_ :: Queue si sm so a -> Signal ()
queueFullChanged_ :: forall si sm so a. Queue si sm so a -> Signal ()
queueFullChanged_ = forall si sm so a. Queue si sm so a -> Signal ()
queueCountChanged_
queueCount :: Queue si sm so a -> Event Int
queueCount :: forall si sm so a. Queue si sm so a -> Event Int
queueCount Queue si sm so a
q =
forall a. (Point -> IO a) -> Event a
Event forall a b. (a -> b) -> a -> b
$ \Point
p -> forall a. IORef a -> IO a
readIORef (forall si sm so a. Queue si sm so a -> IORef Int
queueCountRef Queue si sm so a
q)
queueCountStats :: Queue si sm so a -> Event (TimingStats Int)
queueCountStats :: forall si sm so a. Queue si sm so a -> Event (TimingStats Int)
queueCountStats Queue si sm so a
q =
forall a. (Point -> IO a) -> Event a
Event forall a b. (a -> b) -> a -> b
$ \Point
p -> forall a. IORef a -> IO a
readIORef (forall si sm so a. Queue si sm so a -> IORef (TimingStats Int)
queueCountStatsRef Queue si sm so a
q)
queueCountChanged :: Queue si sm so a -> Signal Int
queueCountChanged :: forall si sm so a. Queue si sm so a -> Signal Int
queueCountChanged Queue si sm so a
q =
forall a b. (a -> Event b) -> Signal a -> Signal b
mapSignalM (forall a b. a -> b -> a
const forall a b. (a -> b) -> a -> b
$ forall si sm so a. Queue si sm so a -> Event Int
queueCount Queue si sm so a
q) (forall si sm so a. Queue si sm so a -> Signal ()
queueCountChanged_ Queue si sm so a
q)
queueCountChanged_ :: Queue si sm so a -> Signal ()
queueCountChanged_ :: forall si sm so a. Queue si sm so a -> Signal ()
queueCountChanged_ Queue si sm so a
q =
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (forall a b. a -> b -> a
const ()) (forall si sm so a. Queue si sm so a -> Signal a
enqueueStored Queue si sm so a
q) forall a. Semigroup a => a -> a -> a
<>
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (forall a b. a -> b -> a
const ()) (forall si sm so a. Queue si sm so a -> Signal a
dequeueExtracted Queue si sm so a
q)
enqueueCount :: Queue si sm so a -> Event Int
enqueueCount :: forall si sm so a. Queue si sm so a -> Event Int
enqueueCount Queue si sm so a
q =
forall a. (Point -> IO a) -> Event a
Event forall a b. (a -> b) -> a -> b
$ \Point
p -> forall a. IORef a -> IO a
readIORef (forall si sm so a. Queue si sm so a -> IORef Int
enqueueCountRef Queue si sm so a
q)
enqueueCountChanged :: Queue si sm so a -> Signal Int
enqueueCountChanged :: forall si sm so a. Queue si sm so a -> Signal Int
enqueueCountChanged Queue si sm so a
q =
forall a b. (a -> Event b) -> Signal a -> Signal b
mapSignalM (forall a b. a -> b -> a
const forall a b. (a -> b) -> a -> b
$ forall si sm so a. Queue si sm so a -> Event Int
enqueueCount Queue si sm so a
q) (forall si sm so a. Queue si sm so a -> Signal ()
enqueueCountChanged_ Queue si sm so a
q)
enqueueCountChanged_ :: Queue si sm so a -> Signal ()
enqueueCountChanged_ :: forall si sm so a. Queue si sm so a -> Signal ()
enqueueCountChanged_ Queue si sm so a
q =
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (forall a b. a -> b -> a
const ()) (forall si sm so a. Queue si sm so a -> Signal a
enqueueInitiated Queue si sm so a
q)
enqueueLostCount :: Queue si sm so a -> Event Int
enqueueLostCount :: forall si sm so a. Queue si sm so a -> Event Int
enqueueLostCount Queue si sm so a
q =
forall a. (Point -> IO a) -> Event a
Event forall a b. (a -> b) -> a -> b
$ \Point
p -> forall a. IORef a -> IO a
readIORef (forall si sm so a. Queue si sm so a -> IORef Int
enqueueLostCountRef Queue si sm so a
q)
enqueueLostCountChanged :: Queue si sm so a -> Signal Int
enqueueLostCountChanged :: forall si sm so a. Queue si sm so a -> Signal Int
enqueueLostCountChanged Queue si sm so a
q =
forall a b. (a -> Event b) -> Signal a -> Signal b
mapSignalM (forall a b. a -> b -> a
const forall a b. (a -> b) -> a -> b
$ forall si sm so a. Queue si sm so a -> Event Int
enqueueLostCount Queue si sm so a
q) (forall si sm so a. Queue si sm so a -> Signal ()
enqueueLostCountChanged_ Queue si sm so a
q)
enqueueLostCountChanged_ :: Queue si sm so a -> Signal ()
enqueueLostCountChanged_ :: forall si sm so a. Queue si sm so a -> Signal ()
enqueueLostCountChanged_ Queue si sm so a
q =
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (forall a b. a -> b -> a
const ()) (forall si sm so a. Queue si sm so a -> Signal a
enqueueLost Queue si sm so a
q)
enqueueStoreCount :: Queue si sm so a -> Event Int
enqueueStoreCount :: forall si sm so a. Queue si sm so a -> Event Int
enqueueStoreCount Queue si sm so a
q =
forall a. (Point -> IO a) -> Event a
Event forall a b. (a -> b) -> a -> b
$ \Point
p -> forall a. IORef a -> IO a
readIORef (forall si sm so a. Queue si sm so a -> IORef Int
enqueueStoreCountRef Queue si sm so a
q)
enqueueStoreCountChanged :: Queue si sm so a -> Signal Int
enqueueStoreCountChanged :: forall si sm so a. Queue si sm so a -> Signal Int
enqueueStoreCountChanged Queue si sm so a
q =
forall a b. (a -> Event b) -> Signal a -> Signal b
mapSignalM (forall a b. a -> b -> a
const forall a b. (a -> b) -> a -> b
$ forall si sm so a. Queue si sm so a -> Event Int
enqueueStoreCount Queue si sm so a
q) (forall si sm so a. Queue si sm so a -> Signal ()
enqueueStoreCountChanged_ Queue si sm so a
q)
enqueueStoreCountChanged_ :: Queue si sm so a -> Signal ()
enqueueStoreCountChanged_ :: forall si sm so a. Queue si sm so a -> Signal ()
enqueueStoreCountChanged_ Queue si sm so a
q =
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (forall a b. a -> b -> a
const ()) (forall si sm so a. Queue si sm so a -> Signal a
enqueueStored Queue si sm so a
q)
dequeueCount :: Queue si sm so a -> Event Int
dequeueCount :: forall si sm so a. Queue si sm so a -> Event Int
dequeueCount Queue si sm so a
q =
forall a. (Point -> IO a) -> Event a
Event forall a b. (a -> b) -> a -> b
$ \Point
p -> forall a. IORef a -> IO a
readIORef (forall si sm so a. Queue si sm so a -> IORef Int
dequeueCountRef Queue si sm so a
q)
dequeueCountChanged :: Queue si sm so a -> Signal Int
dequeueCountChanged :: forall si sm so a. Queue si sm so a -> Signal Int
dequeueCountChanged Queue si sm so a
q =
forall a b. (a -> Event b) -> Signal a -> Signal b
mapSignalM (forall a b. a -> b -> a
const forall a b. (a -> b) -> a -> b
$ forall si sm so a. Queue si sm so a -> Event Int
dequeueCount Queue si sm so a
q) (forall si sm so a. Queue si sm so a -> Signal ()
dequeueCountChanged_ Queue si sm so a
q)
dequeueCountChanged_ :: Queue si sm so a -> Signal ()
dequeueCountChanged_ :: forall si sm so a. Queue si sm so a -> Signal ()
dequeueCountChanged_ Queue si sm so a
q =
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (forall a b. a -> b -> a
const ()) (forall si sm so a. Queue si sm so a -> Signal ()
dequeueRequested Queue si sm so a
q)
dequeueExtractCount :: Queue si sm so a -> Event Int
Queue si sm so a
q =
forall a. (Point -> IO a) -> Event a
Event forall a b. (a -> b) -> a -> b
$ \Point
p -> forall a. IORef a -> IO a
readIORef (forall si sm so a. Queue si sm so a -> IORef Int
dequeueExtractCountRef Queue si sm so a
q)
dequeueExtractCountChanged :: Queue si sm so a -> Signal Int
Queue si sm so a
q =
forall a b. (a -> Event b) -> Signal a -> Signal b
mapSignalM (forall a b. a -> b -> a
const forall a b. (a -> b) -> a -> b
$ forall si sm so a. Queue si sm so a -> Event Int
dequeueExtractCount Queue si sm so a
q) (forall si sm so a. Queue si sm so a -> Signal ()
dequeueExtractCountChanged_ Queue si sm so a
q)
dequeueExtractCountChanged_ :: Queue si sm so a -> Signal ()
Queue si sm so a
q =
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (forall a b. a -> b -> a
const ()) (forall si sm so a. Queue si sm so a -> Signal a
dequeueExtracted Queue si sm so a
q)
queueLoadFactor :: Queue si sm so a -> Event Double
queueLoadFactor :: forall si sm so a. Queue si sm so a -> Event Double
queueLoadFactor Queue si sm so a
q =
forall a. (Point -> IO a) -> Event a
Event forall a b. (a -> b) -> a -> b
$ \Point
p ->
do Int
x <- forall a. IORef a -> IO a
readIORef (forall si sm so a. Queue si sm so a -> IORef Int
queueCountRef Queue si sm so a
q)
let y :: Int
y = forall si sm so a. Queue si sm so a -> Int
queueMaxCount Queue 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 :: Queue si sm so a -> Signal Double
queueLoadFactorChanged :: forall si sm so a. Queue si sm so a -> Signal Double
queueLoadFactorChanged Queue si sm so a
q =
forall a b. (a -> Event b) -> Signal a -> Signal b
mapSignalM (forall a b. a -> b -> a
const forall a b. (a -> b) -> a -> b
$ forall si sm so a. Queue si sm so a -> Event Double
queueLoadFactor Queue si sm so a
q) (forall si sm so a. Queue si sm so a -> Signal ()
queueLoadFactorChanged_ Queue si sm so a
q)
queueLoadFactorChanged_ :: Queue si sm so a -> Signal ()
queueLoadFactorChanged_ :: forall si sm so a. Queue si sm so a -> Signal ()
queueLoadFactorChanged_ Queue si sm so a
q =
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (forall a b. a -> b -> a
const ()) (forall si sm so a. Queue si sm so a -> Signal a
enqueueStored Queue si sm so a
q) forall a. Semigroup a => a -> a -> a
<>
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (forall a b. a -> b -> a
const ()) (forall si sm so a. Queue si sm so a -> Signal a
dequeueExtracted Queue si sm so a
q)
enqueueRate :: Queue si sm so a -> Event Double
enqueueRate :: forall si sm so a. Queue si sm so a -> Event Double
enqueueRate Queue si sm so a
q =
forall a. (Point -> IO a) -> Event a
Event forall a b. (a -> b) -> a -> b
$ \Point
p ->
do Int
x <- forall a. IORef a -> IO a
readIORef (forall si sm so a. Queue si sm so a -> IORef Int
enqueueCountRef Queue si sm so a
q)
let t0 :: Double
t0 = Specs -> Double
spcStartTime forall a b. (a -> b) -> a -> b
$ Point -> Specs
pointSpecs Point
p
t :: Double
t = Point -> Double
pointTime Point
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 :: Queue si sm so a -> Event Double
enqueueStoreRate :: forall si sm so a. Queue si sm so a -> Event Double
enqueueStoreRate Queue si sm so a
q =
forall a. (Point -> IO a) -> Event a
Event forall a b. (a -> b) -> a -> b
$ \Point
p ->
do Int
x <- forall a. IORef a -> IO a
readIORef (forall si sm so a. Queue si sm so a -> IORef Int
enqueueStoreCountRef Queue si sm so a
q)
let t0 :: Double
t0 = Specs -> Double
spcStartTime forall a b. (a -> b) -> a -> b
$ Point -> Specs
pointSpecs Point
p
t :: Double
t = Point -> Double
pointTime Point
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 :: Queue si sm so a -> Event Double
dequeueRate :: forall si sm so a. Queue si sm so a -> Event Double
dequeueRate Queue si sm so a
q =
forall a. (Point -> IO a) -> Event a
Event forall a b. (a -> b) -> a -> b
$ \Point
p ->
do Int
x <- forall a. IORef a -> IO a
readIORef (forall si sm so a. Queue si sm so a -> IORef Int
dequeueCountRef Queue si sm so a
q)
let t0 :: Double
t0 = Specs -> Double
spcStartTime forall a b. (a -> b) -> a -> b
$ Point -> Specs
pointSpecs Point
p
t :: Double
t = Point -> Double
pointTime Point
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 :: Queue si sm so a -> Event Double
Queue si sm so a
q =
forall a. (Point -> IO a) -> Event a
Event forall a b. (a -> b) -> a -> b
$ \Point
p ->
do Int
x <- forall a. IORef a -> IO a
readIORef (forall si sm so a. Queue si sm so a -> IORef Int
dequeueExtractCountRef Queue si sm so a
q)
let t0 :: Double
t0 = Specs -> Double
spcStartTime forall a b. (a -> b) -> a -> b
$ Point -> Specs
pointSpecs Point
p
t :: Double
t = Point -> Double
pointTime Point
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 :: Queue si sm so a -> Event (SamplingStats Double)
queueWaitTime :: forall si sm so a. Queue si sm so a -> Event (SamplingStats Double)
queueWaitTime Queue si sm so a
q =
forall a. (Point -> IO a) -> Event a
Event forall a b. (a -> b) -> a -> b
$ \Point
p -> forall a. IORef a -> IO a
readIORef (forall si sm so a. Queue si sm so a -> IORef (SamplingStats Double)
queueWaitTimeRef Queue si sm so a
q)
queueWaitTimeChanged :: Queue si sm so a -> Signal (SamplingStats Double)
queueWaitTimeChanged :: forall si sm so a.
Queue si sm so a -> Signal (SamplingStats Double)
queueWaitTimeChanged Queue si sm so a
q =
forall a b. (a -> Event b) -> Signal a -> Signal b
mapSignalM (forall a b. a -> b -> a
const forall a b. (a -> b) -> a -> b
$ forall si sm so a. Queue si sm so a -> Event (SamplingStats Double)
queueWaitTime Queue si sm so a
q) (forall si sm so a. Queue si sm so a -> Signal ()
queueWaitTimeChanged_ Queue si sm so a
q)
queueWaitTimeChanged_ :: Queue si sm so a -> Signal ()
queueWaitTimeChanged_ :: forall si sm so a. Queue si sm so a -> Signal ()
queueWaitTimeChanged_ Queue si sm so a
q =
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (forall a b. a -> b -> a
const ()) (forall si sm so a. Queue si sm so a -> Signal a
dequeueExtracted Queue si sm so a
q)
queueTotalWaitTime :: Queue si sm so a -> Event (SamplingStats Double)
queueTotalWaitTime :: forall si sm so a. Queue si sm so a -> Event (SamplingStats Double)
queueTotalWaitTime Queue si sm so a
q =
forall a. (Point -> IO a) -> Event a
Event forall a b. (a -> b) -> a -> b
$ \Point
p -> forall a. IORef a -> IO a
readIORef (forall si sm so a. Queue si sm so a -> IORef (SamplingStats Double)
queueTotalWaitTimeRef Queue si sm so a
q)
queueTotalWaitTimeChanged :: Queue si sm so a -> Signal (SamplingStats Double)
queueTotalWaitTimeChanged :: forall si sm so a.
Queue si sm so a -> Signal (SamplingStats Double)
queueTotalWaitTimeChanged Queue si sm so a
q =
forall a b. (a -> Event b) -> Signal a -> Signal b
mapSignalM (forall a b. a -> b -> a
const forall a b. (a -> b) -> a -> b
$ forall si sm so a. Queue si sm so a -> Event (SamplingStats Double)
queueTotalWaitTime Queue si sm so a
q) (forall si sm so a. Queue si sm so a -> Signal ()
queueTotalWaitTimeChanged_ Queue si sm so a
q)
queueTotalWaitTimeChanged_ :: Queue si sm so a -> Signal ()
queueTotalWaitTimeChanged_ :: forall si sm so a. Queue si sm so a -> Signal ()
queueTotalWaitTimeChanged_ Queue si sm so a
q =
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (forall a b. a -> b -> a
const ()) (forall si sm so a. Queue si sm so a -> Signal a
dequeueExtracted Queue si sm so a
q)
enqueueWaitTime :: Queue si sm so a -> Event (SamplingStats Double)
enqueueWaitTime :: forall si sm so a. Queue si sm so a -> Event (SamplingStats Double)
enqueueWaitTime Queue si sm so a
q =
forall a. (Point -> IO a) -> Event a
Event forall a b. (a -> b) -> a -> b
$ \Point
p -> forall a. IORef a -> IO a
readIORef (forall si sm so a. Queue si sm so a -> IORef (SamplingStats Double)
enqueueWaitTimeRef Queue si sm so a
q)
enqueueWaitTimeChanged :: Queue si sm so a -> Signal (SamplingStats Double)
enqueueWaitTimeChanged :: forall si sm so a.
Queue si sm so a -> Signal (SamplingStats Double)
enqueueWaitTimeChanged Queue si sm so a
q =
forall a b. (a -> Event b) -> Signal a -> Signal b
mapSignalM (forall a b. a -> b -> a
const forall a b. (a -> b) -> a -> b
$ forall si sm so a. Queue si sm so a -> Event (SamplingStats Double)
enqueueWaitTime Queue si sm so a
q) (forall si sm so a. Queue si sm so a -> Signal ()
enqueueWaitTimeChanged_ Queue si sm so a
q)
enqueueWaitTimeChanged_ :: Queue si sm so a -> Signal ()
enqueueWaitTimeChanged_ :: forall si sm so a. Queue si sm so a -> Signal ()
enqueueWaitTimeChanged_ Queue si sm so a
q =
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (forall a b. a -> b -> a
const ()) (forall si sm so a. Queue si sm so a -> Signal a
enqueueStored Queue si sm so a
q)
dequeueWaitTime :: Queue si sm so a -> Event (SamplingStats Double)
dequeueWaitTime :: forall si sm so a. Queue si sm so a -> Event (SamplingStats Double)
dequeueWaitTime Queue si sm so a
q =
forall a. (Point -> IO a) -> Event a
Event forall a b. (a -> b) -> a -> b
$ \Point
p -> forall a. IORef a -> IO a
readIORef (forall si sm so a. Queue si sm so a -> IORef (SamplingStats Double)
dequeueWaitTimeRef Queue si sm so a
q)
dequeueWaitTimeChanged :: Queue si sm so a -> Signal (SamplingStats Double)
dequeueWaitTimeChanged :: forall si sm so a.
Queue si sm so a -> Signal (SamplingStats Double)
dequeueWaitTimeChanged Queue si sm so a
q =
forall a b. (a -> Event b) -> Signal a -> Signal b
mapSignalM (forall a b. a -> b -> a
const forall a b. (a -> b) -> a -> b
$ forall si sm so a. Queue si sm so a -> Event (SamplingStats Double)
dequeueWaitTime Queue si sm so a
q) (forall si sm so a. Queue si sm so a -> Signal ()
dequeueWaitTimeChanged_ Queue si sm so a
q)
dequeueWaitTimeChanged_ :: Queue si sm so a -> Signal ()
dequeueWaitTimeChanged_ :: forall si sm so a. Queue si sm so a -> Signal ()
dequeueWaitTimeChanged_ Queue si sm so a
q =
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (forall a b. a -> b -> a
const ()) (forall si sm so a. Queue si sm so a -> Signal a
dequeueExtracted Queue si sm so a
q)
queueRate :: Queue si sm so a -> Event Double
queueRate :: forall si sm so a. Queue si sm so a -> Event Double
queueRate Queue si sm so a
q =
forall a. (Point -> IO a) -> Event a
Event forall a b. (a -> b) -> a -> b
$ \Point
p ->
do TimingStats Int
x <- forall a. IORef a -> IO a
readIORef (forall si sm so a. Queue si sm so a -> IORef (TimingStats Int)
queueCountStatsRef Queue si sm so a
q)
SamplingStats Double
y <- forall a. IORef a -> IO a
readIORef (forall si sm so a. Queue si sm so a -> IORef (SamplingStats Double)
queueWaitTimeRef Queue 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 :: Queue si sm so a -> Signal Double
queueRateChanged :: forall si sm so a. Queue si sm so a -> Signal Double
queueRateChanged Queue si sm so a
q =
forall a b. (a -> Event b) -> Signal a -> Signal b
mapSignalM (forall a b. a -> b -> a
const forall a b. (a -> b) -> a -> b
$ forall si sm so a. Queue si sm so a -> Event Double
queueRate Queue si sm so a
q) (forall si sm so a. Queue si sm so a -> Signal ()
queueRateChanged_ Queue si sm so a
q)
queueRateChanged_ :: Queue si sm so a -> Signal ()
queueRateChanged_ :: forall si sm so a. Queue si sm so a -> Signal ()
queueRateChanged_ Queue si sm so a
q =
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (forall a b. a -> b -> a
const ()) (forall si sm so a. Queue si sm so a -> Signal a
enqueueStored Queue si sm so a
q) forall a. Semigroup a => a -> a -> a
<>
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (forall a b. a -> b -> a
const ()) (forall si sm so a. Queue si sm so a -> Signal a
dequeueExtracted Queue si sm so a
q)
dequeue :: (DequeueStrategy si,
DequeueStrategy sm,
EnqueueStrategy so)
=> Queue si sm so a
-> Process a
dequeue :: forall si sm so a.
(DequeueStrategy si, DequeueStrategy sm, EnqueueStrategy so) =>
Queue si sm so a -> Process a
dequeue Queue si sm so a
q =
do Double
t <- forall (m :: * -> *) a. EventLift m => Event a -> m a
liftEvent forall a b. (a -> b) -> a -> b
$ forall si sm so a. Queue si sm so a -> Event Double
dequeueRequest Queue si sm so a
q
forall s. EnqueueStrategy s => Resource s -> Process ()
requestResource (forall si sm so a. Queue si sm so a -> Resource so
dequeueRes Queue si sm so a
q)
forall (m :: * -> *) a. EventLift m => Event a -> m a
liftEvent forall a b. (a -> b) -> a -> b
$ forall si sm so a.
(DequeueStrategy si, DequeueStrategy sm) =>
Queue si sm so a -> Double -> Event a
dequeueExtract Queue si sm so a
q Double
t
dequeueWithOutputPriority :: (DequeueStrategy si,
DequeueStrategy sm,
PriorityQueueStrategy so po)
=> Queue si sm so a
-> po
-> Process a
dequeueWithOutputPriority :: forall si sm so po a.
(DequeueStrategy si, DequeueStrategy sm,
PriorityQueueStrategy so po) =>
Queue si sm so a -> po -> Process a
dequeueWithOutputPriority Queue si sm so a
q po
po =
do Double
t <- forall (m :: * -> *) a. EventLift m => Event a -> m a
liftEvent forall a b. (a -> b) -> a -> b
$ forall si sm so a. Queue si sm so a -> Event Double
dequeueRequest Queue si sm so a
q
forall s p.
PriorityQueueStrategy s p =>
Resource s -> p -> Process ()
requestResourceWithPriority (forall si sm so a. Queue si sm so a -> Resource so
dequeueRes Queue si sm so a
q) po
po
forall (m :: * -> *) a. EventLift m => Event a -> m a
liftEvent forall a b. (a -> b) -> a -> b
$ forall si sm so a.
(DequeueStrategy si, DequeueStrategy sm) =>
Queue si sm so a -> Double -> Event a
dequeueExtract Queue si sm so a
q Double
t
tryDequeue :: (DequeueStrategy si,
DequeueStrategy sm)
=> Queue si sm so a
-> Event (Maybe a)
tryDequeue :: forall si sm so a.
(DequeueStrategy si, DequeueStrategy sm) =>
Queue si sm so a -> Event (Maybe a)
tryDequeue Queue si sm so a
q =
do Bool
x <- forall s. Resource s -> Event Bool
tryRequestResourceWithinEvent (forall si sm so a. Queue si sm so a -> Resource so
dequeueRes Queue si sm so a
q)
if Bool
x
then do Double
t <- forall si sm so a. Queue si sm so a -> Event Double
dequeueRequest Queue 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 si sm so a.
(DequeueStrategy si, DequeueStrategy sm) =>
Queue si sm so a -> Double -> Event a
dequeueExtract Queue si sm so a
q Double
t
else forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Maybe a
Nothing
queueDelete :: (Eq a,
DequeueStrategy si,
DeletingQueueStrategy sm,
DequeueStrategy so)
=> Queue si sm so a
-> a
-> Event Bool
queueDelete :: forall a si sm so.
(Eq a, DequeueStrategy si, DeletingQueueStrategy sm,
DequeueStrategy so) =>
Queue si sm so a -> a -> Event Bool
queueDelete Queue 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 si sm so a.
(DequeueStrategy si, DeletingQueueStrategy sm,
DequeueStrategy so) =>
Queue si sm so a -> (a -> Bool) -> Event (Maybe a)
queueDeleteBy Queue si sm so a
q (forall a. Eq a => a -> a -> Bool
== a
a)
queueDelete_ :: (Eq a,
DequeueStrategy si,
DeletingQueueStrategy sm,
DequeueStrategy so)
=> Queue si sm so a
-> a
-> Event ()
queueDelete_ :: forall a si sm so.
(Eq a, DequeueStrategy si, DeletingQueueStrategy sm,
DequeueStrategy so) =>
Queue si sm so a -> a -> Event ()
queueDelete_ Queue 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 si sm so a.
(DequeueStrategy si, DeletingQueueStrategy sm,
DequeueStrategy so) =>
Queue si sm so a -> (a -> Bool) -> Event (Maybe a)
queueDeleteBy Queue si sm so a
q (forall a. Eq a => a -> a -> Bool
== a
a)
queueDeleteBy :: (DequeueStrategy si,
DeletingQueueStrategy sm,
DequeueStrategy so)
=> Queue si sm so a
-> (a -> Bool)
-> Event (Maybe a)
queueDeleteBy :: forall si sm so a.
(DequeueStrategy si, DeletingQueueStrategy sm,
DequeueStrategy so) =>
Queue si sm so a -> (a -> Bool) -> Event (Maybe a)
queueDeleteBy Queue si sm so a
q a -> Bool
pred =
do Bool
x <- forall s. Resource s -> Event Bool
tryRequestResourceWithinEvent (forall si sm so a. Queue si sm so a -> Resource so
dequeueRes Queue si sm so a
q)
if Bool
x
then do Maybe (QueueItem a)
i <- forall s i.
DeletingQueueStrategy s =>
StrategyQueue s i -> (i -> Bool) -> Event (Maybe i)
strategyQueueDeleteBy (forall si sm so a.
Queue si sm so a -> StrategyQueue sm (QueueItem a)
queueStore Queue 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 s. DequeueStrategy s => Resource s -> Event ()
releaseResourceWithinEvent (forall si sm so a. Queue si sm so a -> Resource so
dequeueRes Queue 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 si sm so a. Queue si sm so a -> Event Double
dequeueRequest Queue 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 si sm so a.
(DequeueStrategy si, DequeueStrategy sm) =>
Queue si sm so a -> Double -> QueueItem a -> Event a
dequeuePostExtract Queue 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_ :: (DequeueStrategy si,
DeletingQueueStrategy sm,
DequeueStrategy so)
=> Queue si sm so a
-> (a -> Bool)
-> Event ()
queueDeleteBy_ :: forall si sm so a.
(DequeueStrategy si, DeletingQueueStrategy sm,
DequeueStrategy so) =>
Queue si sm so a -> (a -> Bool) -> Event ()
queueDeleteBy_ Queue 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 si sm so a.
(DequeueStrategy si, DeletingQueueStrategy sm,
DequeueStrategy so) =>
Queue si sm so a -> (a -> Bool) -> Event (Maybe a)
queueDeleteBy Queue si sm so a
q a -> Bool
pred
queueContains :: (Eq a,
DeletingQueueStrategy sm)
=> Queue si sm so a
-> a
-> Event Bool
queueContains :: forall a sm si so.
(Eq a, DeletingQueueStrategy sm) =>
Queue si sm so a -> a -> Event Bool
queueContains Queue 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 sm si so a.
DeletingQueueStrategy sm =>
Queue si sm so a -> (a -> Bool) -> Event (Maybe a)
queueContainsBy Queue si sm so a
q (forall a. Eq a => a -> a -> Bool
== a
a)
queueContainsBy :: DeletingQueueStrategy sm
=> Queue si sm so a
-> (a -> Bool)
-> Event (Maybe a)
queueContainsBy :: forall sm si so a.
DeletingQueueStrategy sm =>
Queue si sm so a -> (a -> Bool) -> Event (Maybe a)
queueContainsBy Queue si sm so a
q a -> Bool
pred =
do Maybe (QueueItem a)
x <- forall s i.
DeletingQueueStrategy s =>
StrategyQueue s i -> (i -> Bool) -> Event (Maybe i)
strategyQueueContainsBy (forall si sm so a.
Queue si sm so a -> StrategyQueue sm (QueueItem a)
queueStore Queue 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 :: (DequeueStrategy si,
DequeueStrategy sm)
=> Queue si sm so a
-> Event ()
clearQueue :: forall si sm so a.
(DequeueStrategy si, DequeueStrategy sm) =>
Queue si sm so a -> Event ()
clearQueue Queue si sm so a
q =
do Maybe a
x <- forall si sm so a.
(DequeueStrategy si, DequeueStrategy sm) =>
Queue si sm so a -> Event (Maybe a)
tryDequeue Queue 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 si sm so a.
(DequeueStrategy si, DequeueStrategy sm) =>
Queue si sm so a -> Event ()
clearQueue Queue si sm so a
q
enqueue :: (EnqueueStrategy si,
EnqueueStrategy sm,
DequeueStrategy so)
=> Queue si sm so a
-> a
-> Process ()
enqueue :: forall si sm so a.
(EnqueueStrategy si, EnqueueStrategy sm, DequeueStrategy so) =>
Queue si sm so a -> a -> Process ()
enqueue Queue si sm so a
q a
a =
do QueueItem a
i <- forall (m :: * -> *) a. EventLift m => Event a -> m a
liftEvent forall a b. (a -> b) -> a -> b
$ forall si sm so a. Queue si sm so a -> a -> Event (QueueItem a)
enqueueInitiate Queue si sm so a
q a
a
forall s. EnqueueStrategy s => Resource s -> Process ()
requestResource (forall si sm so a. Queue si sm so a -> Resource si
enqueueRes Queue si sm so a
q)
forall (m :: * -> *) a. EventLift m => Event a -> m a
liftEvent forall a b. (a -> b) -> a -> b
$ forall sm so si a.
(EnqueueStrategy sm, DequeueStrategy so) =>
Queue si sm so a -> QueueItem a -> Event ()
enqueueStore Queue si sm so a
q QueueItem a
i
enqueueWithInputPriority :: (PriorityQueueStrategy si pi,
EnqueueStrategy sm,
DequeueStrategy so)
=> Queue si sm so a
-> pi
-> a
-> Process ()
enqueueWithInputPriority :: forall si pi sm so a.
(PriorityQueueStrategy si pi, EnqueueStrategy sm,
DequeueStrategy so) =>
Queue si sm so a -> pi -> a -> Process ()
enqueueWithInputPriority Queue si sm so a
q pi
pi a
a =
do QueueItem a
i <- forall (m :: * -> *) a. EventLift m => Event a -> m a
liftEvent forall a b. (a -> b) -> a -> b
$ forall si sm so a. Queue si sm so a -> a -> Event (QueueItem a)
enqueueInitiate Queue si sm so a
q a
a
forall s p.
PriorityQueueStrategy s p =>
Resource s -> p -> Process ()
requestResourceWithPriority (forall si sm so a. Queue si sm so a -> Resource si
enqueueRes Queue si sm so a
q) pi
pi
forall (m :: * -> *) a. EventLift m => Event a -> m a
liftEvent forall a b. (a -> b) -> a -> b
$ forall sm so si a.
(EnqueueStrategy sm, DequeueStrategy so) =>
Queue si sm so a -> QueueItem a -> Event ()
enqueueStore Queue si sm so a
q QueueItem a
i
enqueueWithStoringPriority :: (EnqueueStrategy si,
PriorityQueueStrategy sm pm,
DequeueStrategy so)
=> Queue si sm so a
-> pm
-> a
-> Process ()
enqueueWithStoringPriority :: forall si sm pm so a.
(EnqueueStrategy si, PriorityQueueStrategy sm pm,
DequeueStrategy so) =>
Queue si sm so a -> pm -> a -> Process ()
enqueueWithStoringPriority Queue si sm so a
q pm
pm a
a =
do QueueItem a
i <- forall (m :: * -> *) a. EventLift m => Event a -> m a
liftEvent forall a b. (a -> b) -> a -> b
$ forall si sm so a. Queue si sm so a -> a -> Event (QueueItem a)
enqueueInitiate Queue si sm so a
q a
a
forall s. EnqueueStrategy s => Resource s -> Process ()
requestResource (forall si sm so a. Queue si sm so a -> Resource si
enqueueRes Queue si sm so a
q)
forall (m :: * -> *) a. EventLift m => Event a -> m a
liftEvent forall a b. (a -> b) -> a -> b
$ forall sm pm so si a.
(PriorityQueueStrategy sm pm, DequeueStrategy so) =>
Queue si sm so a -> pm -> QueueItem a -> Event ()
enqueueStoreWithPriority Queue si sm so a
q pm
pm QueueItem a
i
enqueueWithInputStoringPriorities :: (PriorityQueueStrategy si pi,
PriorityQueueStrategy sm pm,
DequeueStrategy so)
=> Queue si sm so a
-> pi
-> pm
-> a
-> Process ()
enqueueWithInputStoringPriorities :: forall si pi sm pm so a.
(PriorityQueueStrategy si pi, PriorityQueueStrategy sm pm,
DequeueStrategy so) =>
Queue si sm so a -> pi -> pm -> a -> Process ()
enqueueWithInputStoringPriorities Queue si sm so a
q pi
pi pm
pm a
a =
do QueueItem a
i <- forall (m :: * -> *) a. EventLift m => Event a -> m a
liftEvent forall a b. (a -> b) -> a -> b
$ forall si sm so a. Queue si sm so a -> a -> Event (QueueItem a)
enqueueInitiate Queue si sm so a
q a
a
forall s p.
PriorityQueueStrategy s p =>
Resource s -> p -> Process ()
requestResourceWithPriority (forall si sm so a. Queue si sm so a -> Resource si
enqueueRes Queue si sm so a
q) pi
pi
forall (m :: * -> *) a. EventLift m => Event a -> m a
liftEvent forall a b. (a -> b) -> a -> b
$ forall sm pm so si a.
(PriorityQueueStrategy sm pm, DequeueStrategy so) =>
Queue si sm so a -> pm -> QueueItem a -> Event ()
enqueueStoreWithPriority Queue si sm so a
q pm
pm QueueItem a
i
tryEnqueue :: (EnqueueStrategy sm,
DequeueStrategy so)
=> Queue si sm so a
-> a
-> Event Bool
tryEnqueue :: forall sm so si a.
(EnqueueStrategy sm, DequeueStrategy so) =>
Queue si sm so a -> a -> Event Bool
tryEnqueue Queue si sm so a
q a
a =
do Bool
x <- forall s. Resource s -> Event Bool
tryRequestResourceWithinEvent (forall si sm so a. Queue si sm so a -> Resource si
enqueueRes Queue si sm so a
q)
if Bool
x
then do forall si sm so a. Queue si sm so a -> a -> Event (QueueItem a)
enqueueInitiate Queue si sm so a
q a
a forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall sm so si a.
(EnqueueStrategy sm, DequeueStrategy so) =>
Queue si sm so a -> QueueItem a -> Event ()
enqueueStore Queue 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 :: (PriorityQueueStrategy sm pm,
DequeueStrategy so)
=> Queue si sm so a
-> pm
-> a
-> Event Bool
tryEnqueueWithStoringPriority :: forall sm pm so si a.
(PriorityQueueStrategy sm pm, DequeueStrategy so) =>
Queue si sm so a -> pm -> a -> Event Bool
tryEnqueueWithStoringPriority Queue si sm so a
q pm
pm a
a =
do Bool
x <- forall s. Resource s -> Event Bool
tryRequestResourceWithinEvent (forall si sm so a. Queue si sm so a -> Resource si
enqueueRes Queue si sm so a
q)
if Bool
x
then do forall si sm so a. Queue si sm so a -> a -> Event (QueueItem a)
enqueueInitiate Queue si sm so a
q a
a forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall sm pm so si a.
(PriorityQueueStrategy sm pm, DequeueStrategy so) =>
Queue si sm so a -> pm -> QueueItem a -> Event ()
enqueueStoreWithPriority Queue 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 :: (EnqueueStrategy sm,
DequeueStrategy so)
=> Queue si sm so a
-> a
-> Event Bool
enqueueOrLost :: forall sm so si a.
(EnqueueStrategy sm, DequeueStrategy so) =>
Queue si sm so a -> a -> Event Bool
enqueueOrLost Queue si sm so a
q a
a =
do Bool
x <- forall s. Resource s -> Event Bool
tryRequestResourceWithinEvent (forall si sm so a. Queue si sm so a -> Resource si
enqueueRes Queue si sm so a
q)
if Bool
x
then do forall si sm so a. Queue si sm so a -> a -> Event (QueueItem a)
enqueueInitiate Queue si sm so a
q a
a forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall sm so si a.
(EnqueueStrategy sm, DequeueStrategy so) =>
Queue si sm so a -> QueueItem a -> Event ()
enqueueStore Queue si sm so a
q
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
True
else do forall si sm so a. Queue si sm so a -> a -> Event ()
enqueueDeny Queue si sm so a
q a
a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False
enqueueWithStoringPriorityOrLost :: (PriorityQueueStrategy sm pm,
DequeueStrategy so)
=> Queue si sm so a
-> pm
-> a
-> Event Bool
enqueueWithStoringPriorityOrLost :: forall sm pm so si a.
(PriorityQueueStrategy sm pm, DequeueStrategy so) =>
Queue si sm so a -> pm -> a -> Event Bool
enqueueWithStoringPriorityOrLost Queue si sm so a
q pm
pm a
a =
do Bool
x <- forall s. Resource s -> Event Bool
tryRequestResourceWithinEvent (forall si sm so a. Queue si sm so a -> Resource si
enqueueRes Queue si sm so a
q)
if Bool
x
then do forall si sm so a. Queue si sm so a -> a -> Event (QueueItem a)
enqueueInitiate Queue si sm so a
q a
a forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall sm pm so si a.
(PriorityQueueStrategy sm pm, DequeueStrategy so) =>
Queue si sm so a -> pm -> QueueItem a -> Event ()
enqueueStoreWithPriority Queue si sm so a
q pm
pm
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
True
else do forall si sm so a. Queue si sm so a -> a -> Event ()
enqueueDeny Queue si sm so a
q a
a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False
enqueueOrLost_ :: (EnqueueStrategy sm,
DequeueStrategy so)
=> Queue si sm so a
-> a
-> Event ()
enqueueOrLost_ :: forall sm so si a.
(EnqueueStrategy sm, DequeueStrategy so) =>
Queue si sm so a -> a -> Event ()
enqueueOrLost_ Queue si sm so a
q a
a =
do Bool
x <- forall sm so si a.
(EnqueueStrategy sm, DequeueStrategy so) =>
Queue si sm so a -> a -> Event Bool
enqueueOrLost Queue si sm so a
q a
a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
enqueueWithStoringPriorityOrLost_ :: (PriorityQueueStrategy sm pm,
DequeueStrategy so)
=> Queue si sm so a
-> pm
-> a
-> Event ()
enqueueWithStoringPriorityOrLost_ :: forall sm pm so si a.
(PriorityQueueStrategy sm pm, DequeueStrategy so) =>
Queue si sm so a -> pm -> a -> Event ()
enqueueWithStoringPriorityOrLost_ Queue si sm so a
q pm
pm a
a =
do Bool
x <- forall sm pm so si a.
(PriorityQueueStrategy sm pm, DequeueStrategy so) =>
Queue si sm so a -> pm -> a -> Event Bool
enqueueWithStoringPriorityOrLost Queue si sm so a
q pm
pm a
a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
enqueueInitiated :: Queue si sm so a -> Signal a
enqueueInitiated :: forall si sm so a. Queue si sm so a -> Signal a
enqueueInitiated Queue si sm so a
q = forall a. SignalSource a -> Signal a
publishSignal (forall si sm so a. Queue si sm so a -> SignalSource a
enqueueInitiatedSource Queue si sm so a
q)
enqueueStored :: Queue si sm so a -> Signal a
enqueueStored :: forall si sm so a. Queue si sm so a -> Signal a
enqueueStored Queue si sm so a
q = forall a. SignalSource a -> Signal a
publishSignal (forall si sm so a. Queue si sm so a -> SignalSource a
enqueueStoredSource Queue si sm so a
q)
enqueueLost :: Queue si sm so a -> Signal a
enqueueLost :: forall si sm so a. Queue si sm so a -> Signal a
enqueueLost Queue si sm so a
q = forall a. SignalSource a -> Signal a
publishSignal (forall si sm so a. Queue si sm so a -> SignalSource a
enqueueLostSource Queue si sm so a
q)
dequeueRequested :: Queue si sm so a -> Signal ()
dequeueRequested :: forall si sm so a. Queue si sm so a -> Signal ()
dequeueRequested Queue si sm so a
q = forall a. SignalSource a -> Signal a
publishSignal (forall si sm so a. Queue si sm so a -> SignalSource ()
dequeueRequestedSource Queue si sm so a
q)
dequeueExtracted :: Queue si sm so a -> Signal a
Queue si sm so a
q = forall a. SignalSource a -> Signal a
publishSignal (forall si sm so a. Queue si sm so a -> SignalSource a
dequeueExtractedSource Queue si sm so a
q)
enqueueInitiate :: Queue si sm so a
-> a
-> Event (QueueItem a)
enqueueInitiate :: forall si sm so a. Queue si sm so a -> a -> Event (QueueItem a)
enqueueInitiate Queue si sm so a
q a
a =
forall a. (Point -> IO a) -> Event a
Event forall a b. (a -> b) -> a -> b
$ \Point
p ->
do let t :: Double
t = Point -> Double
pointTime Point
p
forall a. IORef a -> (a -> a) -> IO ()
modifyIORef' (forall si sm so a. Queue si sm so a -> IORef Int
enqueueCountRef Queue si sm so a
q) (forall a. Num a => a -> a -> a
+ Int
1)
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$
forall a. SignalSource a -> a -> Event ()
triggerSignal (forall si sm so a. Queue si sm so a -> SignalSource a
enqueueInitiatedSource Queue 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 :: (EnqueueStrategy sm,
DequeueStrategy so)
=> Queue si sm so a
-> QueueItem a
-> Event ()
enqueueStore :: forall sm so si a.
(EnqueueStrategy sm, DequeueStrategy so) =>
Queue si sm so a -> QueueItem a -> Event ()
enqueueStore Queue si sm so a
q QueueItem a
i =
forall a. (Point -> IO a) -> Event a
Event forall a b. (a -> b) -> a -> b
$ \Point
p ->
do let i' :: QueueItem a
i' = QueueItem a
i { itemStoringTime :: Double
itemStoringTime = Point -> Double
pointTime Point
p }
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$
forall s i. EnqueueStrategy s => StrategyQueue s i -> i -> Event ()
strategyEnqueue (forall si sm so a.
Queue si sm so a -> StrategyQueue sm (QueueItem a)
queueStore Queue si sm so a
q) QueueItem a
i'
Int
c <- forall a. IORef a -> IO a
readIORef (forall si sm so a. Queue si sm so a -> IORef Int
queueCountRef Queue si sm so a
q)
let c' :: Int
c' = Int
c forall a. Num a => a -> a -> a
+ Int
1
t :: Double
t = Point -> Double
pointTime Point
p
Int
c' seq :: forall a b. a -> b -> b
`seq` forall a. IORef a -> a -> IO ()
writeIORef (forall si sm so a. Queue si sm so a -> IORef Int
queueCountRef Queue si sm so a
q) Int
c'
forall a. IORef a -> (a -> a) -> IO ()
modifyIORef' (forall si sm so a. Queue si sm so a -> IORef (TimingStats Int)
queueCountStatsRef Queue si sm so a
q) (forall a.
TimingData a =>
Double -> a -> TimingStats a -> TimingStats a
addTimingStats Double
t Int
c')
forall a. IORef a -> (a -> a) -> IO ()
modifyIORef' (forall si sm so a. Queue si sm so a -> IORef Int
enqueueStoreCountRef Queue si sm so a
q) (forall a. Num a => a -> a -> a
+ Int
1)
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$
forall si sm so a. Queue si sm so a -> QueueItem a -> Event ()
enqueueStat Queue si sm so a
q QueueItem a
i'
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$
forall s. DequeueStrategy s => Resource s -> Event ()
releaseResourceWithinEvent (forall si sm so a. Queue si sm so a -> Resource so
dequeueRes Queue si sm so a
q)
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$
forall a. SignalSource a -> a -> Event ()
triggerSignal (forall si sm so a. Queue si sm so a -> SignalSource a
enqueueStoredSource Queue si sm so a
q) (forall a. QueueItem a -> a
itemValue QueueItem a
i')
enqueueStoreWithPriority :: (PriorityQueueStrategy sm pm,
DequeueStrategy so)
=> Queue si sm so a
-> pm
-> QueueItem a
-> Event ()
enqueueStoreWithPriority :: forall sm pm so si a.
(PriorityQueueStrategy sm pm, DequeueStrategy so) =>
Queue si sm so a -> pm -> QueueItem a -> Event ()
enqueueStoreWithPriority Queue si sm so a
q pm
pm QueueItem a
i =
forall a. (Point -> IO a) -> Event a
Event forall a b. (a -> b) -> a -> b
$ \Point
p ->
do let i' :: QueueItem a
i' = QueueItem a
i { itemStoringTime :: Double
itemStoringTime = Point -> Double
pointTime Point
p }
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$
forall s p i.
PriorityQueueStrategy s p =>
StrategyQueue s i -> p -> i -> Event ()
strategyEnqueueWithPriority (forall si sm so a.
Queue si sm so a -> StrategyQueue sm (QueueItem a)
queueStore Queue si sm so a
q) pm
pm QueueItem a
i'
Int
c <- forall a. IORef a -> IO a
readIORef (forall si sm so a. Queue si sm so a -> IORef Int
queueCountRef Queue si sm so a
q)
let c' :: Int
c' = Int
c forall a. Num a => a -> a -> a
+ Int
1
t :: Double
t = Point -> Double
pointTime Point
p
Int
c' seq :: forall a b. a -> b -> b
`seq` forall a. IORef a -> a -> IO ()
writeIORef (forall si sm so a. Queue si sm so a -> IORef Int
queueCountRef Queue si sm so a
q) Int
c'
forall a. IORef a -> (a -> a) -> IO ()
modifyIORef' (forall si sm so a. Queue si sm so a -> IORef (TimingStats Int)
queueCountStatsRef Queue si sm so a
q) (forall a.
TimingData a =>
Double -> a -> TimingStats a -> TimingStats a
addTimingStats Double
t Int
c')
forall a. IORef a -> (a -> a) -> IO ()
modifyIORef' (forall si sm so a. Queue si sm so a -> IORef Int
enqueueStoreCountRef Queue si sm so a
q) (forall a. Num a => a -> a -> a
+ Int
1)
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$
forall si sm so a. Queue si sm so a -> QueueItem a -> Event ()
enqueueStat Queue si sm so a
q QueueItem a
i'
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$
forall s. DequeueStrategy s => Resource s -> Event ()
releaseResourceWithinEvent (forall si sm so a. Queue si sm so a -> Resource so
dequeueRes Queue si sm so a
q)
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$
forall a. SignalSource a -> a -> Event ()
triggerSignal (forall si sm so a. Queue si sm so a -> SignalSource a
enqueueStoredSource Queue si sm so a
q) (forall a. QueueItem a -> a
itemValue QueueItem a
i')
enqueueDeny :: Queue si sm so a
-> a
-> Event ()
enqueueDeny :: forall si sm so a. Queue si sm so a -> a -> Event ()
enqueueDeny Queue si sm so a
q a
a =
forall a. (Point -> IO a) -> Event a
Event forall a b. (a -> b) -> a -> b
$ \Point
p ->
do forall a. IORef a -> (a -> a) -> IO ()
modifyIORef' (forall si sm so a. Queue si sm so a -> IORef Int
enqueueLostCountRef Queue si sm so a
q) forall a b. (a -> b) -> a -> b
$ forall a. Num a => a -> a -> a
(+) Int
1
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$
forall a. SignalSource a -> a -> Event ()
triggerSignal (forall si sm so a. Queue si sm so a -> SignalSource a
enqueueLostSource Queue si sm so a
q) a
a
enqueueStat :: Queue si sm so a
-> QueueItem a
-> Event ()
enqueueStat :: forall si sm so a. Queue si sm so a -> QueueItem a -> Event ()
enqueueStat Queue si sm so a
q QueueItem a
i =
forall a. (Point -> IO a) -> Event a
Event forall a b. (a -> b) -> a -> b
$ \Point
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 a. IORef a -> (a -> a) -> IO ()
modifyIORef' (forall si sm so a. Queue si sm so a -> IORef (SamplingStats Double)
enqueueWaitTimeRef Queue 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 :: Queue si sm so a
-> Event Double
dequeueRequest :: forall si sm so a. Queue si sm so a -> Event Double
dequeueRequest Queue si sm so a
q =
forall a. (Point -> IO a) -> Event a
Event forall a b. (a -> b) -> a -> b
$ \Point
p ->
do forall a. IORef a -> (a -> a) -> IO ()
modifyIORef' (forall si sm so a. Queue si sm so a -> IORef Int
dequeueCountRef Queue si sm so a
q) (forall a. Num a => a -> a -> a
+ Int
1)
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$
forall a. SignalSource a -> a -> Event ()
triggerSignal (forall si sm so a. Queue si sm so a -> SignalSource ()
dequeueRequestedSource Queue si sm so a
q) ()
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Point -> Double
pointTime Point
p
dequeueExtract :: (DequeueStrategy si,
DequeueStrategy sm)
=> Queue si sm so a
-> Double
-> Event a
Queue si sm so a
q Double
t' =
forall a. (Point -> IO a) -> Event a
Event forall a b. (a -> b) -> a -> b
$ \Point
p ->
do QueueItem a
i <- forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$
forall s i. DequeueStrategy s => StrategyQueue s i -> Event i
strategyDequeue (forall si sm so a.
Queue si sm so a -> StrategyQueue sm (QueueItem a)
queueStore Queue si sm so a
q)
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$
forall si sm so a.
(DequeueStrategy si, DequeueStrategy sm) =>
Queue si sm so a -> Double -> QueueItem a -> Event a
dequeuePostExtract Queue si sm so a
q Double
t' QueueItem a
i
dequeuePostExtract :: (DequeueStrategy si,
DequeueStrategy sm)
=> Queue si sm so a
-> Double
-> QueueItem a
-> Event a
Queue si sm so a
q Double
t' QueueItem a
i =
forall a. (Point -> IO a) -> Event a
Event forall a b. (a -> b) -> a -> b
$ \Point
p ->
do Int
c <- forall a. IORef a -> IO a
readIORef (forall si sm so a. Queue si sm so a -> IORef Int
queueCountRef Queue si sm so a
q)
let c' :: Int
c' = Int
c forall a. Num a => a -> a -> a
- Int
1
t :: Double
t = Point -> Double
pointTime Point
p
Int
c' seq :: forall a b. a -> b -> b
`seq` forall a. IORef a -> a -> IO ()
writeIORef (forall si sm so a. Queue si sm so a -> IORef Int
queueCountRef Queue si sm so a
q) Int
c'
forall a. IORef a -> (a -> a) -> IO ()
modifyIORef' (forall si sm so a. Queue si sm so a -> IORef (TimingStats Int)
queueCountStatsRef Queue si sm so a
q) (forall a.
TimingData a =>
Double -> a -> TimingStats a -> TimingStats a
addTimingStats Double
t Int
c')
forall a. IORef a -> (a -> a) -> IO ()
modifyIORef' (forall si sm so a. Queue si sm so a -> IORef Int
dequeueExtractCountRef Queue si sm so a
q) (forall a. Num a => a -> a -> a
+ Int
1)
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$
forall si sm so a.
Queue si sm so a -> Double -> QueueItem a -> Event ()
dequeueStat Queue si sm so a
q Double
t' QueueItem a
i
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$
forall s. DequeueStrategy s => Resource s -> Event ()
releaseResourceWithinEvent (forall si sm so a. Queue si sm so a -> Resource si
enqueueRes Queue si sm so a
q)
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$
forall a. SignalSource a -> a -> Event ()
triggerSignal (forall si sm so a. Queue si sm so a -> SignalSource a
dequeueExtractedSource Queue 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 :: Queue si sm so a
-> Double
-> QueueItem a
-> Event ()
dequeueStat :: forall si sm so a.
Queue si sm so a -> Double -> QueueItem a -> Event ()
dequeueStat Queue si sm so a
q Double
t' QueueItem a
i =
forall a. (Point -> IO a) -> Event a
Event forall a b. (a -> b) -> a -> b
$ \Point
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 = Point -> Double
pointTime Point
p
forall a. IORef a -> (a -> a) -> IO ()
modifyIORef' (forall si sm so a. Queue si sm so a -> IORef (SamplingStats Double)
dequeueWaitTimeRef Queue 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 a. IORef a -> (a -> a) -> IO ()
modifyIORef' (forall si sm so a. Queue si sm so a -> IORef (SamplingStats Double)
queueTotalWaitTimeRef Queue 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 a. IORef a -> (a -> a) -> IO ()
modifyIORef' (forall si sm so a. Queue si sm so a -> IORef (SamplingStats Double)
queueWaitTimeRef Queue 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 :: Queue si sm so a -> Process ()
waitWhileFullQueue :: forall si sm so a. Queue si sm so a -> Process ()
waitWhileFullQueue Queue si sm so a
q =
do Bool
x <- forall (m :: * -> *) a. EventLift m => Event a -> m a
liftEvent (forall si sm so a. Queue si sm so a -> Event Bool
queueFull Queue si sm so a
q)
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when Bool
x forall a b. (a -> b) -> a -> b
$
do forall a. Signal a -> Process a
processAwait (forall si sm so a. Queue si sm so a -> Signal a
dequeueExtracted Queue si sm so a
q)
forall si sm so a. Queue si sm so a -> Process ()
waitWhileFullQueue Queue si sm so a
q
queueChanged_ :: Queue si sm so a -> Signal ()
queueChanged_ :: forall si sm so a. Queue si sm so a -> Signal ()
queueChanged_ Queue si sm so a
q =
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (forall a b. a -> b -> a
const ()) (forall si sm so a. Queue si sm so a -> Signal a
enqueueInitiated Queue si sm so a
q) forall a. Semigroup a => a -> a -> a
<>
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (forall a b. a -> b -> a
const ()) (forall si sm so a. Queue si sm so a -> Signal a
enqueueStored Queue si sm so a
q) forall a. Semigroup a => a -> a -> a
<>
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (forall a b. a -> b -> a
const ()) (forall si sm so a. Queue si sm so a -> Signal a
enqueueLost Queue si sm so a
q) forall a. Semigroup a => a -> a -> a
<>
forall si sm so a. Queue si sm so a -> Signal ()
dequeueRequested Queue si sm so a
q forall a. Semigroup a => a -> a -> a
<>
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (forall a b. a -> b -> a
const ()) (forall si sm so a. Queue si sm so a -> Signal a
dequeueExtracted Queue si sm so a
q)
queueSummary :: (Show si, Show sm, Show so) => Queue si sm so a -> Int -> Event ShowS
queueSummary :: forall si sm so a.
(Show si, Show sm, Show so) =>
Queue si sm so a -> Int -> Event ShowS
queueSummary Queue si sm so a
q Int
indent =
do let si :: si
si = forall si sm so a. Queue si sm so a -> si
enqueueStrategy Queue si sm so a
q
sm :: sm
sm = forall si sm so a. Queue si sm so a -> sm
enqueueStoringStrategy Queue si sm so a
q
so :: so
so = forall si sm so a. Queue si sm so a -> so
dequeueStrategy Queue si sm so a
q
Bool
null <- forall si sm so a. Queue si sm so a -> Event Bool
queueNull Queue si sm so a
q
Bool
full <- forall si sm so a. Queue si sm so a -> Event Bool
queueFull Queue si sm so a
q
let maxCount :: Int
maxCount = forall si sm so a. Queue si sm so a -> Int
queueMaxCount Queue si sm so a
q
Int
count <- forall si sm so a. Queue si sm so a -> Event Int
queueCount Queue si sm so a
q
TimingStats Int
countStats <- forall si sm so a. Queue si sm so a -> Event (TimingStats Int)
queueCountStats Queue si sm so a
q
Int
enqueueCount <- forall si sm so a. Queue si sm so a -> Event Int
enqueueCount Queue si sm so a
q
Int
enqueueLostCount <- forall si sm so a. Queue si sm so a -> Event Int
enqueueLostCount Queue si sm so a
q
Int
enqueueStoreCount <- forall si sm so a. Queue si sm so a -> Event Int
enqueueStoreCount Queue si sm so a
q
Int
dequeueCount <- forall si sm so a. Queue si sm so a -> Event Int
dequeueCount Queue si sm so a
q
Int
dequeueExtractCount <- forall si sm so a. Queue si sm so a -> Event Int
dequeueExtractCount Queue si sm so a
q
Double
loadFactor <- forall si sm so a. Queue si sm so a -> Event Double
queueLoadFactor Queue si sm so a
q
Double
enqueueRate <- forall si sm so a. Queue si sm so a -> Event Double
enqueueRate Queue si sm so a
q
Double
enqueueStoreRate <- forall si sm so a. Queue si sm so a -> Event Double
enqueueStoreRate Queue si sm so a
q
Double
dequeueRate <- forall si sm so a. Queue si sm so a -> Event Double
dequeueRate Queue si sm so a
q
Double
dequeueExtractRate <- forall si sm so a. Queue si sm so a -> Event Double
dequeueExtractRate Queue si sm so a
q
SamplingStats Double
waitTime <- forall si sm so a. Queue si sm so a -> Event (SamplingStats Double)
queueWaitTime Queue si sm so a
q
SamplingStats Double
totalWaitTime <- forall si sm so a. Queue si sm so a -> Event (SamplingStats Double)
queueTotalWaitTime Queue si sm so a
q
SamplingStats Double
enqueueWaitTime <- forall si sm so a. Queue si sm so a -> Event (SamplingStats Double)
enqueueWaitTime Queue si sm so a
q
SamplingStats Double
dequeueWaitTime <- forall si sm so a. Queue si sm so a -> Event (SamplingStats Double)
dequeueWaitTime Queue 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 :: Queue si sm so a -> Event ()
resetQueue :: forall si sm so a. Queue si sm so a -> Event ()
resetQueue Queue si sm so a
q =
forall a. (Point -> IO a) -> Event a
Event forall a b. (a -> b) -> a -> b
$ \Point
p ->
do let t :: Double
t = Point -> Double
pointTime Point
p
Int
queueCount <- forall a. IORef a -> IO a
readIORef (forall si sm so a. Queue si sm so a -> IORef Int
queueCountRef Queue si sm so a
q)
forall a. IORef a -> a -> IO ()
writeIORef (forall si sm so a. Queue si sm so a -> IORef (TimingStats Int)
queueCountStatsRef Queue 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 a. IORef a -> a -> IO ()
writeIORef (forall si sm so a. Queue si sm so a -> IORef Int
enqueueCountRef Queue si sm so a
q) Int
0
forall a. IORef a -> a -> IO ()
writeIORef (forall si sm so a. Queue si sm so a -> IORef Int
enqueueLostCountRef Queue si sm so a
q) Int
0
forall a. IORef a -> a -> IO ()
writeIORef (forall si sm so a. Queue si sm so a -> IORef Int
enqueueStoreCountRef Queue si sm so a
q) Int
0
forall a. IORef a -> a -> IO ()
writeIORef (forall si sm so a. Queue si sm so a -> IORef Int
dequeueCountRef Queue si sm so a
q) Int
0
forall a. IORef a -> a -> IO ()
writeIORef (forall si sm so a. Queue si sm so a -> IORef Int
dequeueExtractCountRef Queue si sm so a
q) Int
0
forall a. IORef a -> a -> IO ()
writeIORef (forall si sm so a. Queue si sm so a -> IORef (SamplingStats Double)
queueWaitTimeRef Queue si sm so a
q) forall a. Monoid a => a
mempty
forall a. IORef a -> a -> IO ()
writeIORef (forall si sm so a. Queue si sm so a -> IORef (SamplingStats Double)
queueTotalWaitTimeRef Queue si sm so a
q) forall a. Monoid a => a
mempty
forall a. IORef a -> a -> IO ()
writeIORef (forall si sm so a. Queue si sm so a -> IORef (SamplingStats Double)
enqueueWaitTimeRef Queue si sm so a
q) forall a. Monoid a => a
mempty
forall a. IORef a -> a -> IO ()
writeIORef (forall si sm so a. Queue si sm so a -> IORef (SamplingStats Double)
dequeueWaitTimeRef Queue si sm so a
q) forall a. Monoid a => a
mempty