module Simulation.Aivika.GPSS.Facility
(
Facility,
FacilityPreemptMode(..),
FacilityPreemptTransfer,
newFacility,
facilityCount,
facilityCountStats,
facilityCaptureCount,
facilityUtilisationCount,
facilityUtilisationCountStats,
facilityQueueCount,
facilityQueueCountStats,
facilityTotalWaitTime,
facilityWaitTime,
facilityTotalHoldingTime,
facilityHoldingTime,
facilityInterrupted,
seizeFacility,
releaseFacility,
preemptFacility,
returnFacility,
resetFacility,
facilityCountChanged,
facilityCountChanged_,
facilityCaptureCountChanged,
facilityCaptureCountChanged_,
facilityUtilisationCountChanged,
facilityUtilisationCountChanged_,
facilityQueueCountChanged,
facilityQueueCountChanged_,
facilityWaitTimeChanged,
facilityWaitTimeChanged_,
facilityHoldingTimeChanged,
facilityHoldingTimeChanged_,
facilityChanged_) where
import Data.IORef
import Data.Monoid
import Data.Maybe
import Control.Monad
import Control.Monad.Trans
import Control.Exception
import Simulation.Aivika.Internal.Specs
import Simulation.Aivika.Internal.Simulation
import Simulation.Aivika.Internal.Event
import Simulation.Aivika.Internal.Cont
import Simulation.Aivika.Internal.Process
import Simulation.Aivika.QueueStrategy
import Simulation.Aivika.Statistics
import Simulation.Aivika.Signal
import Simulation.Aivika.GPSS.Transact
import Simulation.Aivika.GPSS.TransactQueueStrategy
data Facility a =
Facility { forall a. Facility a -> IORef Int
facilityCountRef :: IORef Int,
forall a. Facility a -> IORef (TimingStats Int)
facilityCountStatsRef :: IORef (TimingStats Int),
forall a. Facility a -> SignalSource Int
facilityCountSource :: SignalSource Int,
forall a. Facility a -> IORef Int
facilityCaptureCountRef :: IORef Int,
forall a. Facility a -> SignalSource Int
facilityCaptureCountSource :: SignalSource Int,
forall a. Facility a -> IORef Int
facilityUtilisationCountRef :: IORef Int,
forall a. Facility a -> IORef (TimingStats Int)
facilityUtilisationCountStatsRef :: IORef (TimingStats Int),
forall a. Facility a -> SignalSource Int
facilityUtilisationCountSource :: SignalSource Int,
forall a. Facility a -> IORef Int
facilityQueueCountRef :: IORef Int,
forall a. Facility a -> IORef (TimingStats Int)
facilityQueueCountStatsRef :: IORef (TimingStats Int),
forall a. Facility a -> SignalSource Int
facilityQueueCountSource :: SignalSource Int,
forall a. Facility a -> IORef Double
facilityTotalWaitTimeRef :: IORef Double,
forall a. Facility a -> IORef (SamplingStats Double)
facilityWaitTimeRef :: IORef (SamplingStats Double),
forall a. Facility a -> SignalSource ()
facilityWaitTimeSource :: SignalSource (),
forall a. Facility a -> IORef Double
facilityTotalHoldingTimeRef :: IORef Double,
forall a. Facility a -> IORef (SamplingStats Double)
facilityHoldingTimeRef :: IORef (SamplingStats Double),
forall a. Facility a -> SignalSource ()
facilityHoldingTimeSource :: SignalSource (),
forall a. Facility a -> IORef (Maybe (FacilityOwnerItem a))
facilityOwnerRef :: IORef (Maybe (FacilityOwnerItem a)),
forall a.
Facility a
-> StrategyQueue
(TransactQueueStrategy FCFS) (FacilityDelayedItem a)
facilityDelayChain :: StrategyQueue (TransactQueueStrategy FCFS) (FacilityDelayedItem a),
forall a.
Facility a
-> StrategyQueue
(TransactQueueStrategy LCFS) (FacilityInterruptedItem a)
facilityInterruptChain :: StrategyQueue (TransactQueueStrategy LCFS) (FacilityInterruptedItem a),
forall a.
Facility a
-> StrategyQueue
(TransactQueueStrategy FCFS) (FacilityPendingItem a)
facilityPendingChain :: StrategyQueue (TransactQueueStrategy FCFS) (FacilityPendingItem a) }
data FacilityOwnerItem a =
FacilityOwnerItem { forall a. FacilityOwnerItem a -> Transact a
ownerItemTransact :: Transact a,
forall a. FacilityOwnerItem a -> Double
ownerItemTime :: Double,
forall a. FacilityOwnerItem a -> Bool
ownerItemPreempting :: Bool,
forall a. FacilityOwnerItem a -> Bool
ownerItemInterrupting :: Bool,
forall a. FacilityOwnerItem a -> Double
ownerItemAccHoldingTime :: Double }
data FacilityDelayedItem a =
FacilityDelayedItem { forall a. FacilityDelayedItem a -> Transact a
delayedItemTransact :: Transact a,
forall a. FacilityDelayedItem a -> Double
delayedItemTime :: Double,
forall a. FacilityDelayedItem a -> Bool
delayedItemPreempting :: Bool,
forall a. FacilityDelayedItem a -> Bool
delayedItemInterrupting :: Bool,
forall a. FacilityDelayedItem a -> FrozenCont ()
delayedItemCont :: FrozenCont () }
data FacilityInterruptedItem a =
FacilityInterruptedItem { forall a. FacilityInterruptedItem a -> Transact a
interruptedItemTransact :: Transact a,
forall a. FacilityInterruptedItem a -> Double
interruptedItemTime :: Double,
forall a. FacilityInterruptedItem a -> Bool
interruptedItemPreempting :: Bool,
forall a. FacilityInterruptedItem a -> Bool
interruptedItemInterrupting :: Bool,
forall a. FacilityInterruptedItem a -> Maybe Double
interruptedItemRemainingTime :: Maybe Double,
forall a.
FacilityInterruptedItem a -> Maybe (FacilityPreemptTransfer a)
interruptedItemTransfer :: Maybe (FacilityPreemptTransfer a),
forall a. FacilityInterruptedItem a -> Double
interruptedItemAccHoldingTime :: Double }
data FacilityPendingItem a =
FacilityPendingItem { forall a. FacilityPendingItem a -> Transact a
pendingItemTransact :: Transact a,
forall a. FacilityPendingItem a -> Double
pendingItemTime :: Double,
forall a. FacilityPendingItem a -> Bool
pendingItemPreempting :: Bool,
forall a. FacilityPendingItem a -> Bool
pendingItemInterrupting :: Bool,
forall a. FacilityPendingItem a -> FrozenCont ()
pendingItemCont :: FrozenCont () }
instance Eq (Facility a) where
Facility a
x == :: Facility a -> Facility a -> Bool
== Facility a
y = forall a. Facility a -> IORef Int
facilityCountRef Facility a
x forall a. Eq a => a -> a -> Bool
== forall a. Facility a -> IORef Int
facilityCountRef Facility a
y
data FacilityPreemptMode a =
FacilityPreemptMode { forall a. FacilityPreemptMode a -> Bool
facilityPriorityMode :: Bool,
forall a.
FacilityPreemptMode a -> Maybe (FacilityPreemptTransfer a)
facilityTransfer :: Maybe (FacilityPreemptTransfer a),
forall a. FacilityPreemptMode a -> Bool
facilityRemoveMode :: Bool
}
type FacilityPreemptTransfer a = Transact a -> Maybe Double -> Process ()
defaultFacilityPreemptMode :: FacilityPreemptMode a
defaultFacilityPreemptMode :: forall a. FacilityPreemptMode a
defaultFacilityPreemptMode =
FacilityPreemptMode { facilityPriorityMode :: Bool
facilityPriorityMode = Bool
False,
facilityTransfer :: Maybe (FacilityPreemptTransfer a)
facilityTransfer = forall a. Maybe a
Nothing,
facilityRemoveMode :: Bool
facilityRemoveMode = Bool
False
}
newFacility :: Event (Facility a)
newFacility :: forall a. Event (Facility a)
newFacility =
forall a. (Point -> IO a) -> Event a
Event forall a b. (a -> b) -> a -> b
$ \Point
p ->
do let r :: Run
r = Point -> Run
pointRun Point
p
t :: Double
t = Point -> Double
pointTime Point
p
IORef Int
countRef <- forall a. a -> IO (IORef a)
newIORef Int
1
IORef (TimingStats Int)
countStatsRef <- 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
1
SignalSource Int
countSource <- forall a. Run -> Simulation a -> IO a
invokeSimulation Run
r forall a. Simulation (SignalSource a)
newSignalSource
IORef Int
captureCountRef <- forall a. a -> IO (IORef a)
newIORef Int
0
SignalSource Int
captureCountSource <- forall a. Run -> Simulation a -> IO a
invokeSimulation Run
r forall a. Simulation (SignalSource a)
newSignalSource
IORef Int
utilCountRef <- forall a. a -> IO (IORef a)
newIORef Int
0
IORef (TimingStats Int)
utilCountStatsRef <- 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
SignalSource Int
utilCountSource <- forall a. Run -> Simulation a -> IO a
invokeSimulation Run
r forall a. Simulation (SignalSource a)
newSignalSource
IORef Int
queueCountRef <- forall a. a -> IO (IORef a)
newIORef Int
0
IORef (TimingStats Int)
queueCountStatsRef <- 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
SignalSource Int
queueCountSource <- forall a. Run -> Simulation a -> IO a
invokeSimulation Run
r forall a. Simulation (SignalSource a)
newSignalSource
IORef Double
totalWaitTimeRef <- forall a. a -> IO (IORef a)
newIORef Double
0
IORef (SamplingStats Double)
waitTimeRef <- forall a. a -> IO (IORef a)
newIORef forall a. SamplingData a => SamplingStats a
emptySamplingStats
SignalSource ()
waitTimeSource <- forall a. Run -> Simulation a -> IO a
invokeSimulation Run
r forall a. Simulation (SignalSource a)
newSignalSource
IORef Double
totalHoldingTimeRef <- forall a. a -> IO (IORef a)
newIORef Double
0
IORef (SamplingStats Double)
holdingTimeRef <- forall a. a -> IO (IORef a)
newIORef forall a. SamplingData a => SamplingStats a
emptySamplingStats
SignalSource ()
holdingTimeSource <- forall a. Run -> Simulation a -> IO a
invokeSimulation Run
r forall a. Simulation (SignalSource a)
newSignalSource
IORef (Maybe (FacilityOwnerItem a))
ownerRef <- forall a. a -> IO (IORef a)
newIORef forall a. Maybe a
Nothing
StrategyQueue (TransactQueueStrategy FCFS) (FacilityDelayedItem a)
delayChain <- forall a. Run -> Simulation a -> IO a
invokeSimulation Run
r forall a b. (a -> b) -> a -> b
$ forall s i. QueueStrategy s => s -> Simulation (StrategyQueue s i)
newStrategyQueue (forall s. s -> TransactQueueStrategy s
TransactQueueStrategy FCFS
FCFS)
StrategyQueue
(TransactQueueStrategy LCFS) (FacilityInterruptedItem a)
interruptChain <- forall a. Run -> Simulation a -> IO a
invokeSimulation Run
r forall a b. (a -> b) -> a -> b
$ forall s i. QueueStrategy s => s -> Simulation (StrategyQueue s i)
newStrategyQueue (forall s. s -> TransactQueueStrategy s
TransactQueueStrategy LCFS
LCFS)
StrategyQueue (TransactQueueStrategy FCFS) (FacilityPendingItem a)
pendingChain <- forall a. Run -> Simulation a -> IO a
invokeSimulation Run
r forall a b. (a -> b) -> a -> b
$ forall s i. QueueStrategy s => s -> Simulation (StrategyQueue s i)
newStrategyQueue (forall s. s -> TransactQueueStrategy s
TransactQueueStrategy FCFS
FCFS)
forall (m :: * -> *) a. Monad m => a -> m a
return Facility { facilityCountRef :: IORef Int
facilityCountRef = IORef Int
countRef,
facilityCountStatsRef :: IORef (TimingStats Int)
facilityCountStatsRef = IORef (TimingStats Int)
countStatsRef,
facilityCountSource :: SignalSource Int
facilityCountSource = SignalSource Int
countSource,
facilityCaptureCountRef :: IORef Int
facilityCaptureCountRef = IORef Int
captureCountRef,
facilityCaptureCountSource :: SignalSource Int
facilityCaptureCountSource = SignalSource Int
captureCountSource,
facilityUtilisationCountRef :: IORef Int
facilityUtilisationCountRef = IORef Int
utilCountRef,
facilityUtilisationCountStatsRef :: IORef (TimingStats Int)
facilityUtilisationCountStatsRef = IORef (TimingStats Int)
utilCountStatsRef,
facilityUtilisationCountSource :: SignalSource Int
facilityUtilisationCountSource = SignalSource Int
utilCountSource,
facilityQueueCountRef :: IORef Int
facilityQueueCountRef = IORef Int
queueCountRef,
facilityQueueCountStatsRef :: IORef (TimingStats Int)
facilityQueueCountStatsRef = IORef (TimingStats Int)
queueCountStatsRef,
facilityQueueCountSource :: SignalSource Int
facilityQueueCountSource = SignalSource Int
queueCountSource,
facilityTotalWaitTimeRef :: IORef Double
facilityTotalWaitTimeRef = IORef Double
totalWaitTimeRef,
facilityWaitTimeRef :: IORef (SamplingStats Double)
facilityWaitTimeRef = IORef (SamplingStats Double)
waitTimeRef,
facilityWaitTimeSource :: SignalSource ()
facilityWaitTimeSource = SignalSource ()
waitTimeSource,
facilityTotalHoldingTimeRef :: IORef Double
facilityTotalHoldingTimeRef = IORef Double
totalHoldingTimeRef,
facilityHoldingTimeRef :: IORef (SamplingStats Double)
facilityHoldingTimeRef = IORef (SamplingStats Double)
holdingTimeRef,
facilityHoldingTimeSource :: SignalSource ()
facilityHoldingTimeSource = SignalSource ()
holdingTimeSource,
facilityOwnerRef :: IORef (Maybe (FacilityOwnerItem a))
facilityOwnerRef = IORef (Maybe (FacilityOwnerItem a))
ownerRef,
facilityDelayChain :: StrategyQueue (TransactQueueStrategy FCFS) (FacilityDelayedItem a)
facilityDelayChain = StrategyQueue (TransactQueueStrategy FCFS) (FacilityDelayedItem a)
delayChain,
facilityInterruptChain :: StrategyQueue
(TransactQueueStrategy LCFS) (FacilityInterruptedItem a)
facilityInterruptChain = StrategyQueue
(TransactQueueStrategy LCFS) (FacilityInterruptedItem a)
interruptChain,
facilityPendingChain :: StrategyQueue (TransactQueueStrategy FCFS) (FacilityPendingItem a)
facilityPendingChain = StrategyQueue (TransactQueueStrategy FCFS) (FacilityPendingItem a)
pendingChain }
facilityCount :: Facility a -> Event Int
facilityCount :: forall a. Facility a -> Event Int
facilityCount Facility a
r =
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 a. Facility a -> IORef Int
facilityCountRef Facility a
r)
facilityCountStats :: Facility a -> Event (TimingStats Int)
facilityCountStats :: forall a. Facility a -> Event (TimingStats Int)
facilityCountStats Facility a
r =
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 a. Facility a -> IORef (TimingStats Int)
facilityCountStatsRef Facility a
r)
facilityCountChanged :: Facility a -> Signal Int
facilityCountChanged :: forall a. Facility a -> Signal Int
facilityCountChanged Facility a
r =
forall a. SignalSource a -> Signal a
publishSignal forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> SignalSource Int
facilityCountSource Facility a
r
facilityCountChanged_ :: Facility a -> Signal ()
facilityCountChanged_ :: forall a. Facility a -> Signal ()
facilityCountChanged_ Facility a
r =
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (forall a b. a -> b -> a
const ()) forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> Signal Int
facilityCountChanged Facility a
r
facilityCaptureCount :: Facility a -> Event Int
facilityCaptureCount :: forall a. Facility a -> Event Int
facilityCaptureCount Facility a
r =
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 a. Facility a -> IORef Int
facilityCaptureCountRef Facility a
r)
facilityCaptureCountChanged :: Facility a -> Signal Int
facilityCaptureCountChanged :: forall a. Facility a -> Signal Int
facilityCaptureCountChanged Facility a
r =
forall a. SignalSource a -> Signal a
publishSignal forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> SignalSource Int
facilityCaptureCountSource Facility a
r
facilityCaptureCountChanged_ :: Facility a -> Signal ()
facilityCaptureCountChanged_ :: forall a. Facility a -> Signal ()
facilityCaptureCountChanged_ Facility a
r =
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (forall a b. a -> b -> a
const ()) forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> Signal Int
facilityCaptureCountChanged Facility a
r
facilityUtilisationCount :: Facility a -> Event Int
facilityUtilisationCount :: forall a. Facility a -> Event Int
facilityUtilisationCount Facility a
r =
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 a. Facility a -> IORef Int
facilityUtilisationCountRef Facility a
r)
facilityUtilisationCountStats :: Facility a -> Event (TimingStats Int)
facilityUtilisationCountStats :: forall a. Facility a -> Event (TimingStats Int)
facilityUtilisationCountStats Facility a
r =
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 a. Facility a -> IORef (TimingStats Int)
facilityUtilisationCountStatsRef Facility a
r)
facilityUtilisationCountChanged :: Facility a -> Signal Int
facilityUtilisationCountChanged :: forall a. Facility a -> Signal Int
facilityUtilisationCountChanged Facility a
r =
forall a. SignalSource a -> Signal a
publishSignal forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> SignalSource Int
facilityUtilisationCountSource Facility a
r
facilityUtilisationCountChanged_ :: Facility a -> Signal ()
facilityUtilisationCountChanged_ :: forall a. Facility a -> Signal ()
facilityUtilisationCountChanged_ Facility a
r =
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (forall a b. a -> b -> a
const ()) forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> Signal Int
facilityUtilisationCountChanged Facility a
r
facilityQueueCount :: Facility a -> Event Int
facilityQueueCount :: forall a. Facility a -> Event Int
facilityQueueCount Facility a
r =
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 a. Facility a -> IORef Int
facilityQueueCountRef Facility a
r)
facilityQueueCountStats :: Facility a -> Event (TimingStats Int)
facilityQueueCountStats :: forall a. Facility a -> Event (TimingStats Int)
facilityQueueCountStats Facility a
r =
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 a. Facility a -> IORef (TimingStats Int)
facilityQueueCountStatsRef Facility a
r)
facilityQueueCountChanged :: Facility a -> Signal Int
facilityQueueCountChanged :: forall a. Facility a -> Signal Int
facilityQueueCountChanged Facility a
r =
forall a. SignalSource a -> Signal a
publishSignal forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> SignalSource Int
facilityQueueCountSource Facility a
r
facilityQueueCountChanged_ :: Facility a -> Signal ()
facilityQueueCountChanged_ :: forall a. Facility a -> Signal ()
facilityQueueCountChanged_ Facility a
r =
forall a b. (a -> b) -> Signal a -> Signal b
mapSignal (forall a b. a -> b -> a
const ()) forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> Signal Int
facilityQueueCountChanged Facility a
r
facilityTotalWaitTime :: Facility a -> Event Double
facilityTotalWaitTime :: forall a. Facility a -> Event Double
facilityTotalWaitTime Facility a
r =
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 a. Facility a -> IORef Double
facilityTotalWaitTimeRef Facility a
r)
facilityWaitTime :: Facility a -> Event (SamplingStats Double)
facilityWaitTime :: forall a. Facility a -> Event (SamplingStats Double)
facilityWaitTime Facility a
r =
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 a. Facility a -> IORef (SamplingStats Double)
facilityWaitTimeRef Facility a
r)
facilityWaitTimeChanged :: Facility a -> Signal (SamplingStats Double)
facilityWaitTimeChanged :: forall a. Facility a -> Signal (SamplingStats Double)
facilityWaitTimeChanged Facility a
r =
forall a b. (a -> Event b) -> Signal a -> Signal b
mapSignalM (\() -> forall a. Facility a -> Event (SamplingStats Double)
facilityWaitTime Facility a
r) forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> Signal ()
facilityWaitTimeChanged_ Facility a
r
facilityWaitTimeChanged_ :: Facility a -> Signal ()
facilityWaitTimeChanged_ :: forall a. Facility a -> Signal ()
facilityWaitTimeChanged_ Facility a
r =
forall a. SignalSource a -> Signal a
publishSignal forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> SignalSource ()
facilityWaitTimeSource Facility a
r
facilityTotalHoldingTime :: Facility a -> Event Double
facilityTotalHoldingTime :: forall a. Facility a -> Event Double
facilityTotalHoldingTime Facility a
r =
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 a. Facility a -> IORef Double
facilityTotalHoldingTimeRef Facility a
r)
facilityHoldingTime :: Facility a -> Event (SamplingStats Double)
facilityHoldingTime :: forall a. Facility a -> Event (SamplingStats Double)
facilityHoldingTime Facility a
r =
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 a. Facility a -> IORef (SamplingStats Double)
facilityHoldingTimeRef Facility a
r)
facilityHoldingTimeChanged :: Facility a -> Signal (SamplingStats Double)
facilityHoldingTimeChanged :: forall a. Facility a -> Signal (SamplingStats Double)
facilityHoldingTimeChanged Facility a
r =
forall a b. (a -> Event b) -> Signal a -> Signal b
mapSignalM (\() -> forall a. Facility a -> Event (SamplingStats Double)
facilityHoldingTime Facility a
r) forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> Signal ()
facilityHoldingTimeChanged_ Facility a
r
facilityHoldingTimeChanged_ :: Facility a -> Signal ()
facilityHoldingTimeChanged_ :: forall a. Facility a -> Signal ()
facilityHoldingTimeChanged_ Facility a
r =
forall a. SignalSource a -> Signal a
publishSignal forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> SignalSource ()
facilityHoldingTimeSource Facility a
r
facilityInterrupted :: Facility a -> Event Bool
facilityInterrupted :: forall a. Facility a -> Event Bool
facilityInterrupted Facility a
r =
forall a. (Point -> IO a) -> Event a
Event forall a b. (a -> b) -> a -> b
$ \Point
p ->
do Maybe (FacilityOwnerItem a)
x <- forall a. IORef a -> IO a
readIORef (forall a. Facility a -> IORef (Maybe (FacilityOwnerItem a))
facilityOwnerRef Facility a
r)
case Maybe (FacilityOwnerItem a)
x of
Maybe (FacilityOwnerItem a)
Nothing -> forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False
Just FacilityOwnerItem a
a -> forall (m :: * -> *) a. Monad m => a -> m a
return (forall a. FacilityOwnerItem a -> Bool
ownerItemPreempting FacilityOwnerItem a
a)
seizeFacility :: Facility a
-> Transact a
-> Process ()
seizeFacility :: forall a. Facility a -> Transact a -> Process ()
seizeFacility Facility a
r Transact a
transact =
forall a. (ProcessId -> Cont a) -> Process a
Process forall a b. (a -> b) -> a -> b
$ \ProcessId
pid ->
forall a. (ContParams a -> Event ()) -> Cont a
Cont forall a b. (a -> b) -> a -> b
$ \ContParams ()
c ->
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
Bool
f <- do Bool
f1 <- forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall s i. QueueStrategy s => StrategyQueue s i -> Event Bool
strategyQueueNull (forall a.
Facility a
-> StrategyQueue
(TransactQueueStrategy FCFS) (FacilityDelayedItem a)
facilityDelayChain Facility a
r)
if Bool
f1
then do Bool
f2 <- forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall s i. QueueStrategy s => StrategyQueue s i -> Event Bool
strategyQueueNull (forall a.
Facility a
-> StrategyQueue
(TransactQueueStrategy LCFS) (FacilityInterruptedItem a)
facilityInterruptChain Facility a
r)
if Bool
f2
then forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall s i. QueueStrategy s => StrategyQueue s i -> Event Bool
strategyQueueNull (forall a.
Facility a
-> StrategyQueue
(TransactQueueStrategy FCFS) (FacilityPendingItem a)
facilityPendingChain Facility a
r)
else forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False
else forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False
if Bool
f
then forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$
forall a. ContParams a -> Cont a -> Event ()
invokeCont ContParams ()
c forall a b. (a -> b) -> a -> b
$
forall a. ProcessId -> Process a -> Cont a
invokeProcess ProcessId
pid forall a b. (a -> b) -> a -> b
$
forall a. Facility a -> Transact a -> Process ()
seizeFacility' Facility a
r Transact a
transact
else do FrozenCont ()
c <- forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$
forall a. ContParams a -> a -> Event () -> Event (FrozenCont a)
freezeContReentering ContParams ()
c () forall a b. (a -> b) -> a -> b
$
forall a. ContParams a -> Cont a -> Event ()
invokeCont ContParams ()
c forall a b. (a -> b) -> a -> b
$
forall a. ProcessId -> Process a -> Cont a
invokeProcess ProcessId
pid forall a b. (a -> b) -> a -> b
$
forall a. Facility a -> Transact a -> Process ()
seizeFacility Facility a
r Transact a
transact
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 a.
Facility a
-> StrategyQueue
(TransactQueueStrategy FCFS) (FacilityDelayedItem a)
facilityDelayChain Facility a
r)
(forall a. Transact a -> Int
transactPriority Transact a
transact)
(forall a.
Transact a
-> Double -> Bool -> Bool -> FrozenCont () -> FacilityDelayedItem a
FacilityDelayedItem Transact a
transact Double
t Bool
False Bool
False FrozenCont ()
c)
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> Int -> Event ()
updateFacilityQueueCount Facility a
r Int
1
seizeFacility' :: Facility a
-> Transact a
-> Process ()
seizeFacility' :: forall a. Facility a -> Transact a -> Process ()
seizeFacility' Facility a
r Transact a
transact =
forall a. (ProcessId -> Cont a) -> Process a
Process forall a b. (a -> b) -> a -> b
$ \ProcessId
pid ->
forall a. (ContParams a -> Event ()) -> Cont a
Cont forall a b. (a -> b) -> a -> b
$ \ContParams ()
c ->
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
Maybe (FacilityOwnerItem a)
a <- forall a. IORef a -> IO a
readIORef (forall a. Facility a -> IORef (Maybe (FacilityOwnerItem a))
facilityOwnerRef Facility a
r)
case Maybe (FacilityOwnerItem a)
a of
Maybe (FacilityOwnerItem a)
Nothing ->
do forall a. IORef a -> a -> IO ()
writeIORef (forall a. Facility a -> IORef (Maybe (FacilityOwnerItem a))
facilityOwnerRef Facility a
r) forall a b. (a -> b) -> a -> b
$ forall a. a -> Maybe a
Just (forall a.
Transact a
-> Double -> Bool -> Bool -> Double -> FacilityOwnerItem a
FacilityOwnerItem Transact a
transact Double
t Bool
False Bool
False Double
0)
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> Double -> Event ()
updateFacilityWaitTime Facility a
r Double
0
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> Int -> Event ()
updateFacilityCount Facility a
r (-Int
1)
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> Int -> Event ()
updateFacilityCaptureCount Facility a
r Int
1
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> Int -> Event ()
updateFacilityUtilisationCount Facility a
r Int
1
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. ContParams a -> a -> Event ()
resumeCont ContParams ()
c ()
Just FacilityOwnerItem a
owner ->
do FrozenCont ()
c <- forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$
forall a. ContParams a -> a -> Event () -> Event (FrozenCont a)
freezeContReentering ContParams ()
c () forall a b. (a -> b) -> a -> b
$
forall a. ContParams a -> Cont a -> Event ()
invokeCont ContParams ()
c forall a b. (a -> b) -> a -> b
$
forall a. ProcessId -> Process a -> Cont a
invokeProcess ProcessId
pid forall a b. (a -> b) -> a -> b
$
forall a. Facility a -> Transact a -> Process ()
seizeFacility Facility a
r Transact a
transact
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 a.
Facility a
-> StrategyQueue
(TransactQueueStrategy FCFS) (FacilityDelayedItem a)
facilityDelayChain Facility a
r)
(forall a. Transact a -> Int
transactPriority Transact a
transact)
(forall a.
Transact a
-> Double -> Bool -> Bool -> FrozenCont () -> FacilityDelayedItem a
FacilityDelayedItem Transact a
transact Double
t Bool
False Bool
False FrozenCont ()
c)
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> Int -> Event ()
updateFacilityQueueCount Facility a
r Int
1
preemptFacility :: Facility a
-> Transact a
-> FacilityPreemptMode a
-> Process ()
preemptFacility :: forall a.
Facility a -> Transact a -> FacilityPreemptMode a -> Process ()
preemptFacility Facility a
r Transact a
transact FacilityPreemptMode a
mode =
forall a. (ProcessId -> Cont a) -> Process a
Process forall a b. (a -> b) -> a -> b
$ \ProcessId
pid ->
forall a. (ContParams a -> Event ()) -> Cont a
Cont forall a b. (a -> b) -> a -> b
$ \ContParams ()
c ->
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
Maybe (FacilityOwnerItem a)
a <- forall a. IORef a -> IO a
readIORef (forall a. Facility a -> IORef (Maybe (FacilityOwnerItem a))
facilityOwnerRef Facility a
r)
case Maybe (FacilityOwnerItem a)
a of
Maybe (FacilityOwnerItem a)
Nothing ->
do forall a. IORef a -> a -> IO ()
writeIORef (forall a. Facility a -> IORef (Maybe (FacilityOwnerItem a))
facilityOwnerRef Facility a
r) forall a b. (a -> b) -> a -> b
$ forall a. a -> Maybe a
Just (forall a.
Transact a
-> Double -> Bool -> Bool -> Double -> FacilityOwnerItem a
FacilityOwnerItem Transact a
transact Double
t Bool
True Bool
False Double
0)
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> Double -> Event ()
updateFacilityWaitTime Facility a
r Double
0
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> Int -> Event ()
updateFacilityCount Facility a
r (-Int
1)
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> Int -> Event ()
updateFacilityCaptureCount Facility a
r Int
1
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> Int -> Event ()
updateFacilityUtilisationCount Facility a
r Int
1
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. ContParams a -> a -> Event ()
resumeCont ContParams ()
c ()
Just owner :: FacilityOwnerItem a
owner@(FacilityOwnerItem Transact a
transact0 Double
t0 Bool
preempting0 Bool
interrupting0 Double
acc0)
| (Bool -> Bool
not forall a b. (a -> b) -> a -> b
$ forall a. FacilityPreemptMode a -> Bool
facilityPriorityMode FacilityPreemptMode a
mode) Bool -> Bool -> Bool
&& Bool
interrupting0 ->
do FrozenCont ()
c <- forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$
forall a. ContParams a -> a -> Event () -> Event (FrozenCont a)
freezeContReentering ContParams ()
c () forall a b. (a -> b) -> a -> b
$
forall a. ContParams a -> Cont a -> Event ()
invokeCont ContParams ()
c forall a b. (a -> b) -> a -> b
$
forall a. ProcessId -> Process a -> Cont a
invokeProcess ProcessId
pid forall a b. (a -> b) -> a -> b
$
forall a.
Facility a -> Transact a -> FacilityPreemptMode a -> Process ()
preemptFacility Facility a
r Transact a
transact FacilityPreemptMode a
mode
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 a.
Facility a
-> StrategyQueue
(TransactQueueStrategy FCFS) (FacilityPendingItem a)
facilityPendingChain Facility a
r)
(forall a. Transact a -> Int
transactPriority Transact a
transact)
(forall a.
Transact a
-> Double -> Bool -> Bool -> FrozenCont () -> FacilityPendingItem a
FacilityPendingItem Transact a
transact Double
t Bool
True Bool
True FrozenCont ()
c)
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> Int -> Event ()
updateFacilityQueueCount Facility a
r Int
1
Just owner :: FacilityOwnerItem a
owner@(FacilityOwnerItem Transact a
transact0 Double
t0 Bool
preempting0 Bool
interrupting0 Double
acc0)
| forall a. FacilityPreemptMode a -> Bool
facilityPriorityMode FacilityPreemptMode a
mode Bool -> Bool -> Bool
&& (forall a. Transact a -> Int
transactPriority Transact a
transact forall a. Ord a => a -> a -> Bool
<= forall a. Transact a -> Int
transactPriority Transact a
transact0) ->
do FrozenCont ()
c <- forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$
forall a. ContParams a -> a -> Event () -> Event (FrozenCont a)
freezeContReentering ContParams ()
c () forall a b. (a -> b) -> a -> b
$
forall a. ContParams a -> Cont a -> Event ()
invokeCont ContParams ()
c forall a b. (a -> b) -> a -> b
$
forall a. ProcessId -> Process a -> Cont a
invokeProcess ProcessId
pid forall a b. (a -> b) -> a -> b
$
forall a.
Facility a -> Transact a -> FacilityPreemptMode a -> Process ()
preemptFacility Facility a
r Transact a
transact FacilityPreemptMode a
mode
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 a.
Facility a
-> StrategyQueue
(TransactQueueStrategy FCFS) (FacilityDelayedItem a)
facilityDelayChain Facility a
r)
(forall a. Transact a -> Int
transactPriority Transact a
transact)
(forall a.
Transact a
-> Double -> Bool -> Bool -> FrozenCont () -> FacilityDelayedItem a
FacilityDelayedItem Transact a
transact Double
t Bool
True Bool
True FrozenCont ()
c)
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> Int -> Event ()
updateFacilityQueueCount Facility a
r Int
1
Just owner :: FacilityOwnerItem a
owner@(FacilityOwnerItem Transact a
transact0 Double
t0 Bool
preempting0 Bool
interrupting0 Double
acc0)
| (Bool -> Bool
not forall a b. (a -> b) -> a -> b
$ forall a. FacilityPreemptMode a -> Bool
facilityRemoveMode FacilityPreemptMode a
mode) ->
do forall a. IORef a -> a -> IO ()
writeIORef (forall a. Facility a -> IORef (Maybe (FacilityOwnerItem a))
facilityOwnerRef Facility a
r) forall a b. (a -> b) -> a -> b
$ forall a. a -> Maybe a
Just (forall a.
Transact a
-> Double -> Bool -> Bool -> Double -> FacilityOwnerItem a
FacilityOwnerItem Transact a
transact Double
t Bool
True Bool
True Double
0)
ProcessId
pid0 <- forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. Transact a -> Event ProcessId
requireTransactProcessId Transact a
transact0
Maybe Double
t2 <- forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ ProcessId -> Event (Maybe Double)
processInterruptionTime ProcessId
pid0
let dt0 :: Maybe Double
dt0 = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\Double
x -> Double
x forall a. Num a => a -> a -> a
- Double
t) Maybe Double
t2
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 a.
Facility a
-> StrategyQueue
(TransactQueueStrategy LCFS) (FacilityInterruptedItem a)
facilityInterruptChain Facility a
r)
(forall a. Transact a -> Int
transactPriority Transact a
transact0)
(forall a.
Transact a
-> Double
-> Bool
-> Bool
-> Maybe Double
-> Maybe (FacilityPreemptTransfer a)
-> Double
-> FacilityInterruptedItem a
FacilityInterruptedItem Transact a
transact0 Double
t Bool
preempting0 Bool
interrupting0 Maybe Double
dt0 (forall a.
FacilityPreemptMode a -> Maybe (FacilityPreemptTransfer a)
facilityTransfer FacilityPreemptMode a
mode) (Double
acc0 forall a. Num a => a -> a -> a
+ (Double
t forall a. Num a => a -> a -> a
- Double
t0)))
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> Int -> Event ()
updateFacilityQueueCount Facility a
r Int
1
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> Double -> Event ()
updateFacilityWaitTime Facility a
r Double
0
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> Int -> Event ()
updateFacilityCaptureCount Facility a
r Int
1
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. Transact a -> Event ()
transactPreemptionBegin Transact a
transact0
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. ContParams a -> a -> Event ()
resumeCont ContParams ()
c ()
Just owner :: FacilityOwnerItem a
owner@(FacilityOwnerItem Transact a
transact0 Double
t0 Bool
preempting0 Bool
interrupting0 Double
acc0)
| forall a. FacilityPreemptMode a -> Bool
facilityRemoveMode FacilityPreemptMode a
mode ->
do forall a. IORef a -> a -> IO ()
writeIORef (forall a. Facility a -> IORef (Maybe (FacilityOwnerItem a))
facilityOwnerRef Facility a
r) forall a b. (a -> b) -> a -> b
$ forall a. a -> Maybe a
Just (forall a.
Transact a
-> Double -> Bool -> Bool -> Double -> FacilityOwnerItem a
FacilityOwnerItem Transact a
transact Double
t Bool
True Bool
True Double
0)
ProcessId
pid0 <- forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. Transact a -> Event ProcessId
requireTransactProcessId Transact a
transact0
Maybe Double
t2 <- forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ ProcessId -> Event (Maybe Double)
processInterruptionTime ProcessId
pid0
let dt0 :: Maybe Double
dt0 = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\Double
x -> Double
x forall a. Num a => a -> a -> a
- Double
t) Maybe Double
t2
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> Double -> Event ()
updateFacilityWaitTime Facility a
r Double
0
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> Int -> Event ()
updateFacilityCaptureCount Facility a
r Int
1
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> Double -> Event ()
updateFacilityHoldingTime Facility a
r (Double
acc0 forall a. Num a => a -> a -> a
+ (Double
t forall a. Num a => a -> a -> a
- Double
t0))
case forall a.
FacilityPreemptMode a -> Maybe (FacilityPreemptTransfer a)
facilityTransfer FacilityPreemptMode a
mode of
Maybe (FacilityPreemptTransfer a)
Nothing ->
forall e a. Exception e => e -> IO a
throwIO forall a b. (a -> b) -> a -> b
$
String -> SimulationRetry
SimulationRetry
String
"The transfer destination is not specified for the removed preempted transact: preemptFacility"
Just FacilityPreemptTransfer a
transfer ->
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. Transact a -> Process () -> Event ()
transferTransact Transact a
transact0 (FacilityPreemptTransfer a
transfer Transact a
transact0 Maybe Double
dt0)
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. ContParams a -> a -> Event ()
resumeCont ContParams ()
c ()
returnFacility :: Facility a
-> Transact a
-> Process ()
returnFacility :: forall a. Facility a -> Transact a -> Process ()
returnFacility Facility a
r Transact a
transact = forall a. Facility a -> Transact a -> Bool -> Process ()
releaseFacility' Facility a
r Transact a
transact Bool
True
releaseFacility :: Facility a
-> Transact a
-> Process ()
releaseFacility :: forall a. Facility a -> Transact a -> Process ()
releaseFacility Facility a
r Transact a
transact = forall a. Facility a -> Transact a -> Bool -> Process ()
releaseFacility' Facility a
r Transact a
transact Bool
False
releaseFacility' :: Facility a
-> Transact a
-> Bool
-> Process ()
releaseFacility' :: forall a. Facility a -> Transact a -> Bool -> Process ()
releaseFacility' Facility a
r Transact a
transact Bool
preempting =
forall a. (ProcessId -> Cont a) -> Process a
Process forall a b. (a -> b) -> a -> b
$ \ProcessId
pid ->
forall a. (ContParams a -> Event ()) -> Cont a
Cont forall a b. (a -> b) -> a -> b
$ \ContParams ()
c ->
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
Maybe (FacilityOwnerItem a)
a <- forall a. IORef a -> IO a
readIORef (forall a. Facility a -> IORef (Maybe (FacilityOwnerItem a))
facilityOwnerRef Facility a
r)
case Maybe (FacilityOwnerItem a)
a of
Maybe (FacilityOwnerItem a)
Nothing ->
forall e a. Exception e => e -> IO a
throwIO forall a b. (a -> b) -> a -> b
$
String -> SimulationRetry
SimulationRetry
String
"There is no owner of the facility: releaseFacility'"
Just owner :: FacilityOwnerItem a
owner@(FacilityOwnerItem Transact a
transact0 Double
t0 Bool
preempting0 Bool
interrupting0 Double
acc0) | Transact a
transact0 forall a. Eq a => a -> a -> Bool
== Transact a
transact Bool -> Bool -> Bool
&& Bool
preempting0 forall a. Eq a => a -> a -> Bool
/= Bool
preempting ->
forall e a. Exception e => e -> IO a
throwIO forall a b. (a -> b) -> a -> b
$
String -> SimulationRetry
SimulationRetry
String
"The mismatch use of releaseFacility and returnFacility: releaseFacility'"
Just owner :: FacilityOwnerItem a
owner@(FacilityOwnerItem Transact a
transact0 Double
t0 Bool
preempting0 Bool
interrupting0 Double
acc0) | Transact a
transact0 forall a. Eq a => a -> a -> Bool
== Transact a
transact ->
do forall a. IORef a -> a -> IO ()
writeIORef (forall a. Facility a -> IORef (Maybe (FacilityOwnerItem a))
facilityOwnerRef Facility a
r) forall a. Maybe a
Nothing
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> Int -> Event ()
updateFacilityUtilisationCount Facility a
r (-Int
1)
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> Double -> Event ()
updateFacilityHoldingTime Facility a
r (Double
acc0 forall a. Num a => a -> a -> a
+ (Double
t forall a. Num a => a -> a -> a
- Double
t0))
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> Int -> Event ()
updateFacilityCount Facility a
r Int
1
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ Double -> Event () -> Event ()
enqueueEvent Double
t forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> Event ()
tryCaptureFacility Facility a
r
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. ContParams a -> a -> Event ()
resumeCont ContParams ()
c ()
Just FacilityOwnerItem a
owner ->
forall e a. Exception e => e -> IO a
throwIO forall a b. (a -> b) -> a -> b
$
String -> SimulationRetry
SimulationRetry
String
"The facility has another owner: releaseFacility'"
tryCaptureFacility :: Facility a -> Event ()
tryCaptureFacility :: forall a. Facility a -> Event ()
tryCaptureFacility Facility a
r =
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
Maybe (FacilityOwnerItem a)
a <- forall a. IORef a -> IO a
readIORef (forall a. Facility a -> IORef (Maybe (FacilityOwnerItem a))
facilityOwnerRef Facility a
r)
case Maybe (FacilityOwnerItem a)
a of
Maybe (FacilityOwnerItem a)
Nothing ->
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> Event ()
captureFacility Facility a
r
Just FacilityOwnerItem a
owner -> forall (m :: * -> *) a. Monad m => a -> m a
return ()
captureFacility :: Facility a -> Event ()
captureFacility :: forall a. Facility a -> Event ()
captureFacility Facility a
r =
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
Bool
f <- forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall s i. QueueStrategy s => StrategyQueue s i -> Event Bool
strategyQueueNull (forall a.
Facility a
-> StrategyQueue
(TransactQueueStrategy FCFS) (FacilityPendingItem a)
facilityPendingChain Facility a
r)
if Bool -> Bool
not Bool
f
then do FacilityPendingItem Transact a
transact Double
t0 Bool
preempting Bool
interrupting FrozenCont ()
c0 <- 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 a.
Facility a
-> StrategyQueue
(TransactQueueStrategy FCFS) (FacilityPendingItem a)
facilityPendingChain Facility a
r)
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> Int -> Event ()
updateFacilityQueueCount Facility a
r (-Int
1)
Maybe (ContParams ())
c <- forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. FrozenCont a -> Event (Maybe (ContParams a))
unfreezeCont FrozenCont ()
c0
case Maybe (ContParams ())
c of
Maybe (ContParams ())
Nothing ->
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> Event ()
captureFacility Facility a
r
Just ContParams ()
c ->
do forall a. IORef a -> a -> IO ()
writeIORef (forall a. Facility a -> IORef (Maybe (FacilityOwnerItem a))
facilityOwnerRef Facility a
r) forall a b. (a -> b) -> a -> b
$ forall a. a -> Maybe a
Just (forall a.
Transact a
-> Double -> Bool -> Bool -> Double -> FacilityOwnerItem a
FacilityOwnerItem Transact a
transact Double
t Bool
preempting Bool
interrupting Double
0)
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> Double -> Event ()
updateFacilityWaitTime Facility a
r (Double
t forall a. Num a => a -> a -> a
- Double
t0)
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> Int -> Event ()
updateFacilityUtilisationCount Facility a
r Int
1
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> Int -> Event ()
updateFacilityCaptureCount Facility a
r Int
1
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> Int -> Event ()
updateFacilityCount Facility a
r (-Int
1)
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ Double -> Event () -> Event ()
enqueueEvent Double
t forall a b. (a -> b) -> a -> b
$ forall a. ContParams a -> a -> Event ()
reenterCont ContParams ()
c ()
else do Bool
f <- forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall s i. QueueStrategy s => StrategyQueue s i -> Event Bool
strategyQueueNull (forall a.
Facility a
-> StrategyQueue
(TransactQueueStrategy LCFS) (FacilityInterruptedItem a)
facilityInterruptChain Facility a
r)
if Bool -> Bool
not Bool
f
then do FacilityInterruptedItem Transact a
transact Double
t0 Bool
preempting Bool
interrupting Maybe Double
dt0 Maybe (FacilityPreemptTransfer a)
transfer0 Double
acc0 <- 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 a.
Facility a
-> StrategyQueue
(TransactQueueStrategy LCFS) (FacilityInterruptedItem a)
facilityInterruptChain Facility a
r)
ProcessId
pid <- forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. Transact a -> Event ProcessId
requireTransactProcessId Transact a
transact
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> Int -> Event ()
updateFacilityQueueCount Facility a
r (-Int
1)
Bool
f <- forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ ProcessId -> Event Bool
processCancelled ProcessId
pid
case Bool
f of
Bool
True ->
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> Event ()
captureFacility Facility a
r
Bool
False ->
do forall a. IORef a -> a -> IO ()
writeIORef (forall a. Facility a -> IORef (Maybe (FacilityOwnerItem a))
facilityOwnerRef Facility a
r) forall a b. (a -> b) -> a -> b
$ forall a. a -> Maybe a
Just (forall a.
Transact a
-> Double -> Bool -> Bool -> Double -> FacilityOwnerItem a
FacilityOwnerItem Transact a
transact Double
t Bool
preempting Bool
interrupting Double
acc0)
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> Double -> Event ()
updateFacilityWaitTime Facility a
r (Double
t forall a. Num a => a -> a -> a
- Double
t0)
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> Int -> Event ()
updateFacilityUtilisationCount Facility a
r Int
1
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> Int -> Event ()
updateFacilityCount Facility a
r (-Int
1)
case Maybe (FacilityPreemptTransfer a)
transfer0 of
Maybe (FacilityPreemptTransfer a)
Nothing -> forall (m :: * -> *) a. Monad m => a -> m a
return ()
Just FacilityPreemptTransfer a
transfer ->
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. Transact a -> Process () -> Event ()
transferTransact Transact a
transact (FacilityPreemptTransfer a
transfer Transact a
transact Maybe Double
dt0)
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. Transact a -> Event ()
transactPreemptionEnd Transact a
transact
else do Bool
f <- forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall s i. QueueStrategy s => StrategyQueue s i -> Event Bool
strategyQueueNull (forall a.
Facility a
-> StrategyQueue
(TransactQueueStrategy FCFS) (FacilityDelayedItem a)
facilityDelayChain Facility a
r)
if Bool -> Bool
not Bool
f
then do FacilityDelayedItem Transact a
transact Double
t0 Bool
preempting Bool
interrupting FrozenCont ()
c0 <- 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 a.
Facility a
-> StrategyQueue
(TransactQueueStrategy FCFS) (FacilityDelayedItem a)
facilityDelayChain Facility a
r)
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> Int -> Event ()
updateFacilityQueueCount Facility a
r (-Int
1)
Maybe (ContParams ())
c <- forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. FrozenCont a -> Event (Maybe (ContParams a))
unfreezeCont FrozenCont ()
c0
case Maybe (ContParams ())
c of
Maybe (ContParams ())
Nothing ->
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> Event ()
captureFacility Facility a
r
Just ContParams ()
c ->
do forall a. IORef a -> a -> IO ()
writeIORef (forall a. Facility a -> IORef (Maybe (FacilityOwnerItem a))
facilityOwnerRef Facility a
r) forall a b. (a -> b) -> a -> b
$ forall a. a -> Maybe a
Just (forall a.
Transact a
-> Double -> Bool -> Bool -> Double -> FacilityOwnerItem a
FacilityOwnerItem Transact a
transact Double
t Bool
preempting Bool
interrupting Double
0)
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> Double -> Event ()
updateFacilityWaitTime Facility a
r (Double
t forall a. Num a => a -> a -> a
- Double
t0)
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> Int -> Event ()
updateFacilityUtilisationCount Facility a
r Int
1
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> Int -> Event ()
updateFacilityCaptureCount Facility a
r Int
1
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ forall a. Facility a -> Int -> Event ()
updateFacilityCount Facility a
r (-Int
1)
forall a. Point -> Event a -> IO a
invokeEvent Point
p forall a b. (a -> b) -> a -> b
$ Double -> Event () -> Event ()
enqueueEvent Double
t forall a b. (a -> b) -> a -> b
$ forall a. ContParams a -> a -> Event ()
reenterCont ContParams ()
c ()
else forall (m :: * -> *) a. Monad m => a -> m a
return ()
facilityChanged_ :: Facility a -> Signal ()
facilityChanged_ :: forall a. Facility a -> Signal ()
facilityChanged_ Facility a
r =
forall a. Facility a -> Signal ()
facilityCountChanged_ Facility a
r forall a. Semigroup a => a -> a -> a
<>
forall a. Facility a -> Signal ()
facilityCaptureCountChanged_ Facility a
r forall a. Semigroup a => a -> a -> a
<>
forall a. Facility a -> Signal ()
facilityUtilisationCountChanged_ Facility a
r forall a. Semigroup a => a -> a -> a
<>
forall a. Facility a -> Signal ()
facilityQueueCountChanged_ Facility a
r
updateFacilityCount :: Facility a -> Int -> Event ()
updateFacilityCount :: forall a. Facility a -> Int -> Event ()
updateFacilityCount Facility a
r Int
delta =
forall a. (Point -> IO a) -> Event a
Event forall a b. (a -> b) -> a -> b
$ \Point
p ->
do Int
a <- forall a. IORef a -> IO a
readIORef (forall a. Facility a -> IORef Int
facilityCountRef Facility a
r)
let a' :: Int
a' = Int
a forall a. Num a => a -> a -> a
+ Int
delta
Int
a' seq :: forall a b. a -> b -> b
`seq` forall a. IORef a -> a -> IO ()
writeIORef (forall a. Facility a -> IORef Int
facilityCountRef Facility a
r) Int
a'
forall a. IORef a -> (a -> a) -> IO ()
modifyIORef' (forall a. Facility a -> IORef (TimingStats Int)
facilityCountStatsRef Facility a
r) forall a b. (a -> b) -> a -> b
$
forall a.
TimingData a =>
Double -> a -> TimingStats a -> TimingStats a
addTimingStats (Point -> Double
pointTime Point
p) Int
a'
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 a. Facility a -> SignalSource Int
facilityCountSource Facility a
r) Int
a'
updateFacilityCaptureCount :: Facility a -> Int -> Event ()
updateFacilityCaptureCount :: forall a. Facility a -> Int -> Event ()
updateFacilityCaptureCount Facility a
r Int
delta =
forall a. (Point -> IO a) -> Event a
Event forall a b. (a -> b) -> a -> b
$ \Point
p ->
do Int
a <- forall a. IORef a -> IO a
readIORef (forall a. Facility a -> IORef Int
facilityCaptureCountRef Facility a
r)
let a' :: Int
a' = Int
a forall a. Num a => a -> a -> a
+ Int
delta
Int
a' seq :: forall a b. a -> b -> b
`seq` forall a. IORef a -> a -> IO ()
writeIORef (forall a. Facility a -> IORef Int
facilityCaptureCountRef Facility a
r) Int
a'
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 a. Facility a -> SignalSource Int
facilityCaptureCountSource Facility a
r) Int
a'
updateFacilityQueueCount :: Facility a -> Int -> Event ()
updateFacilityQueueCount :: forall a. Facility a -> Int -> Event ()
updateFacilityQueueCount Facility a
r Int
delta =
forall a. (Point -> IO a) -> Event a
Event forall a b. (a -> b) -> a -> b
$ \Point
p ->
do Int
a <- forall a. IORef a -> IO a
readIORef (forall a. Facility a -> IORef Int
facilityQueueCountRef Facility a
r)
let a' :: Int
a' = Int
a forall a. Num a => a -> a -> a
+ Int
delta
Int
a' seq :: forall a b. a -> b -> b
`seq` forall a. IORef a -> a -> IO ()
writeIORef (forall a. Facility a -> IORef Int
facilityQueueCountRef Facility a
r) Int
a'
forall a. IORef a -> (a -> a) -> IO ()
modifyIORef' (forall a. Facility a -> IORef (TimingStats Int)
facilityQueueCountStatsRef Facility a
r) forall a b. (a -> b) -> a -> b
$
forall a.
TimingData a =>
Double -> a -> TimingStats a -> TimingStats a
addTimingStats (Point -> Double
pointTime Point
p) Int
a'
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 a. Facility a -> SignalSource Int
facilityQueueCountSource Facility a
r) Int
a'
updateFacilityUtilisationCount :: Facility a -> Int -> Event ()
updateFacilityUtilisationCount :: forall a. Facility a -> Int -> Event ()
updateFacilityUtilisationCount Facility a
r Int
delta =
forall a. (Point -> IO a) -> Event a
Event forall a b. (a -> b) -> a -> b
$ \Point
p ->
do Int
a <- forall a. IORef a -> IO a
readIORef (forall a. Facility a -> IORef Int
facilityUtilisationCountRef Facility a
r)
let a' :: Int
a' = Int
a forall a. Num a => a -> a -> a
+ Int
delta
Int
a' seq :: forall a b. a -> b -> b
`seq` forall a. IORef a -> a -> IO ()
writeIORef (forall a. Facility a -> IORef Int
facilityUtilisationCountRef Facility a
r) Int
a'
forall a. IORef a -> (a -> a) -> IO ()
modifyIORef' (forall a. Facility a -> IORef (TimingStats Int)
facilityUtilisationCountStatsRef Facility a
r) forall a b. (a -> b) -> a -> b
$
forall a.
TimingData a =>
Double -> a -> TimingStats a -> TimingStats a
addTimingStats (Point -> Double
pointTime Point
p) Int
a'
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 a. Facility a -> SignalSource Int
facilityUtilisationCountSource Facility a
r) Int
a'
updateFacilityWaitTime :: Facility a -> Double -> Event ()
updateFacilityWaitTime :: forall a. Facility a -> Double -> Event ()
updateFacilityWaitTime Facility a
r Double
delta =
forall a. (Point -> IO a) -> Event a
Event forall a b. (a -> b) -> a -> b
$ \Point
p ->
do Double
a <- forall a. IORef a -> IO a
readIORef (forall a. Facility a -> IORef Double
facilityTotalWaitTimeRef Facility a
r)
let a' :: Double
a' = Double
a forall a. Num a => a -> a -> a
+ Double
delta
Double
a' seq :: forall a b. a -> b -> b
`seq` forall a. IORef a -> a -> IO ()
writeIORef (forall a. Facility a -> IORef Double
facilityTotalWaitTimeRef Facility a
r) Double
a'
forall a. IORef a -> (a -> a) -> IO ()
modifyIORef' (forall a. Facility a -> IORef (SamplingStats Double)
facilityWaitTimeRef Facility a
r) forall a b. (a -> b) -> a -> b
$
forall a. SamplingData a => a -> SamplingStats a -> SamplingStats a
addSamplingStats Double
delta
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 a. Facility a -> SignalSource ()
facilityWaitTimeSource Facility a
r) ()
updateFacilityHoldingTime :: Facility a -> Double -> Event ()
updateFacilityHoldingTime :: forall a. Facility a -> Double -> Event ()
updateFacilityHoldingTime Facility a
r Double
delta =
forall a. (Point -> IO a) -> Event a
Event forall a b. (a -> b) -> a -> b
$ \Point
p ->
do Double
a <- forall a. IORef a -> IO a
readIORef (forall a. Facility a -> IORef Double
facilityTotalHoldingTimeRef Facility a
r)
let a' :: Double
a' = Double
a forall a. Num a => a -> a -> a
+ Double
delta
Double
a' seq :: forall a b. a -> b -> b
`seq` forall a. IORef a -> a -> IO ()
writeIORef (forall a. Facility a -> IORef Double
facilityTotalHoldingTimeRef Facility a
r) Double
a'
forall a. IORef a -> (a -> a) -> IO ()
modifyIORef' (forall a. Facility a -> IORef (SamplingStats Double)
facilityHoldingTimeRef Facility a
r) forall a b. (a -> b) -> a -> b
$
forall a. SamplingData a => a -> SamplingStats a -> SamplingStats a
addSamplingStats Double
delta
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 a. Facility a -> SignalSource ()
facilityHoldingTimeSource Facility a
r) ()
resetFacility :: Facility a -> Event ()
resetFacility :: forall a. Facility a -> Event ()
resetFacility Facility a
r =
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
count <- forall a. IORef a -> IO a
readIORef (forall a. Facility a -> IORef Int
facilityCountRef Facility a
r)
forall a. IORef a -> a -> IO ()
writeIORef (forall a. Facility a -> IORef (TimingStats Int)
facilityCountStatsRef Facility a
r) forall a b. (a -> b) -> a -> b
$
forall a. TimingData a => Double -> a -> TimingStats a
returnTimingStats Double
t Int
count
forall a. IORef a -> a -> IO ()
writeIORef (forall a. Facility a -> IORef Int
facilityCaptureCountRef Facility a
r) Int
0
Int
utilCount <- forall a. IORef a -> IO a
readIORef (forall a. Facility a -> IORef Int
facilityUtilisationCountRef Facility a
r)
forall a. IORef a -> a -> IO ()
writeIORef (forall a. Facility a -> IORef (TimingStats Int)
facilityUtilisationCountStatsRef Facility a
r) forall a b. (a -> b) -> a -> b
$
forall a. TimingData a => Double -> a -> TimingStats a
returnTimingStats Double
t Int
utilCount
Int
queueCount <- forall a. IORef a -> IO a
readIORef (forall a. Facility a -> IORef Int
facilityQueueCountRef Facility a
r)
forall a. IORef a -> a -> IO ()
writeIORef (forall a. Facility a -> IORef (TimingStats Int)
facilityQueueCountStatsRef Facility a
r) 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 a. Facility a -> IORef Double
facilityTotalWaitTimeRef Facility a
r) Double
0
forall a. IORef a -> a -> IO ()
writeIORef (forall a. Facility a -> IORef (SamplingStats Double)
facilityWaitTimeRef Facility a
r) forall a. SamplingData a => SamplingStats a
emptySamplingStats
forall a. IORef a -> a -> IO ()
writeIORef (forall a. Facility a -> IORef Double
facilityTotalHoldingTimeRef Facility a
r) Double
0
forall a. IORef a -> a -> IO ()
writeIORef (forall a. Facility a -> IORef (SamplingStats Double)
facilityHoldingTimeRef Facility a
r) forall a. SamplingData a => SamplingStats a
emptySamplingStats
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 a. Facility a -> SignalSource Int
facilityCaptureCountSource Facility a
r) Int
0
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 a. Facility a -> SignalSource ()
facilityWaitTimeSource Facility a
r) ()
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 a. Facility a -> SignalSource ()
facilityHoldingTimeSource Facility a
r) ()