aivika 4.1 → 4.1.1
raw patch · 6 files changed
+268/−67 lines, 6 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Simulation.Aivika.Resource: resourceQueueCount :: Resource s -> Event Int
+ Simulation.Aivika.Resource: resourceQueueCountChanged :: Resource s -> Signal Int
+ Simulation.Aivika.Resource: resourceQueueCountChanged_ :: Resource s -> Signal ()
+ Simulation.Aivika.Resource: resourceQueueCountStats :: Resource s -> Event (TimingStats Int)
+ Simulation.Aivika.Resource: resourceTotalWaitTime :: Resource s -> Event Double
+ Simulation.Aivika.Resource: resourceWaitTime :: Resource s -> Event (SamplingStats Double)
+ Simulation.Aivika.Resource: resourceWaitTimeChanged :: Resource s -> Signal (SamplingStats Double)
+ Simulation.Aivika.Resource: resourceWaitTimeChanged_ :: Resource s -> Signal ()
+ Simulation.Aivika.Resource.Preemption: resourceQueueCount :: Resource -> Event Int
+ Simulation.Aivika.Resource.Preemption: resourceQueueCountChanged :: Resource -> Signal Int
+ Simulation.Aivika.Resource.Preemption: resourceQueueCountChanged_ :: Resource -> Signal ()
+ Simulation.Aivika.Resource.Preemption: resourceQueueCountStats :: Resource -> Event (TimingStats Int)
+ Simulation.Aivika.Resource.Preemption: resourceTotalWaitTime :: Resource -> Event Double
+ Simulation.Aivika.Resource.Preemption: resourceWaitTime :: Resource -> Event (SamplingStats Double)
+ Simulation.Aivika.Resource.Preemption: resourceWaitTimeChanged :: Resource -> Signal (SamplingStats Double)
+ Simulation.Aivika.Resource.Preemption: resourceWaitTimeChanged_ :: Resource -> Signal ()
+ Simulation.Aivika.Results.Locale: ResourceQueueCountId :: ResultId
+ Simulation.Aivika.Results.Locale: ResourceQueueCountStatsId :: ResultId
+ Simulation.Aivika.Results.Locale: ResourceTotalWaitTimeId :: ResultId
+ Simulation.Aivika.Results.Locale: ResourceWaitTimeId :: ResultId
Files
- CHANGELOG.md +11/−0
- Simulation/Aivika/Resource.hs +115/−33
- Simulation/Aivika/Resource/Preemption.hs +113/−33
- Simulation/Aivika/Results.hs +12/−0
- Simulation/Aivika/Results/Locale.hs +16/−0
- aivika.cabal +1/−1
CHANGELOG.md view
@@ -1,3 +1,14 @@++Version 4.1.1+-----++* More counters and statistics for the new resources.++Version 4.1+-----++* Added new resource types with counters and statistics.+ Version 4.0.2 -----
Simulation/Aivika/Resource.hs view
@@ -38,6 +38,10 @@ resourceCountStats, resourceUtilisationCount, resourceUtilisationCountStats,+ resourceQueueCount,+ resourceQueueCountStats,+ resourceTotalWaitTime,+ resourceWaitTime, -- * Requesting for and Releasing Resource requestResource, requestResourceWithPriority,@@ -54,6 +58,10 @@ resourceCountChanged_, resourceUtilisationCountChanged, resourceUtilisationCountChanged_,+ resourceQueueCountChanged,+ resourceQueueCountChanged_,+ resourceWaitTimeChanged,+ resourceWaitTimeChanged_, resourceChanged_) where import Data.IORef@@ -101,8 +109,18 @@ resourceUtilisationCountRef :: IORef Int, resourceUtilisationCountStatsRef :: IORef (TimingStats Int), resourceUtilisationCountSource :: SignalSource Int,- resourceWaitList :: StrategyQueue s (FrozenCont ()) }+ resourceQueueCountRef :: IORef Int,+ resourceQueueCountStatsRef :: IORef (TimingStats Int),+ resourceQueueCountSource :: SignalSource Int,+ resourceTotalWaitTimeRef :: IORef Double,+ resourceWaitTimeRef :: IORef (SamplingStats Double),+ resourceWaitTimeSource :: SignalSource (),+ resourceWaitList :: StrategyQueue s ResourceItem } +data ResourceItem =+ ResourceItem { resourceItemTime :: Double,+ resourceItemCont :: FrozenCont () }+ instance Eq (Resource s) where x == y = resourceCountRef x == resourceCountRef y -- unique references @@ -179,29 +197,7 @@ -- ^ the initial count (and maximal count too) of the resource -> Event (Resource s) newResource s count =- Event $ \p ->- do let r = pointRun p- t = pointTime p- when (count < 0) $- error $- "The resource count cannot be negative: " ++- "newResource."- countRef <- newIORef count- countStatsRef <- newIORef $ returnTimingStats t count- countSource <- invokeSimulation r newSignalSource - utilCountRef <- newIORef 0- utilCountStatsRef <- newIORef $ returnTimingStats t 0- utilCountSource <- invokeSimulation r newSignalSource - waitList <- invokeSimulation r $ newStrategyQueue s- return Resource { resourceStrategy = s,- resourceMaxCount = Just count,- resourceCountRef = countRef,- resourceCountStatsRef = countStatsRef,- resourceCountSource = countSource,- resourceUtilisationCountRef = utilCountRef,- resourceUtilisationCountStatsRef = utilCountStatsRef,- resourceUtilisationCountSource = utilCountSource,- resourceWaitList = waitList }+ newResourceWithMaxCount s count (Just count) -- | Create a new resource with the specified queue strategy, initial and maximum counts, -- where 'Nothing' means that the resource has no upper bound.@@ -234,6 +230,12 @@ utilCountRef <- newIORef 0 utilCountStatsRef <- newIORef $ returnTimingStats t 0 utilCountSource <- invokeSimulation r newSignalSource+ queueCountRef <- newIORef 0+ queueCountStatsRef <- newIORef $ returnTimingStats t 0+ queueCountSource <- invokeSimulation r newSignalSource+ totalWaitTimeRef <- newIORef 0+ waitTimeRef <- newIORef emptySamplingStats+ waitTimeSource <- invokeSimulation r newSignalSource waitList <- invokeSimulation r $ newStrategyQueue s return Resource { resourceStrategy = s, resourceMaxCount = maxCount,@@ -243,6 +245,12 @@ resourceUtilisationCountRef = utilCountRef, resourceUtilisationCountStatsRef = utilCountStatsRef, resourceUtilisationCountSource = utilCountSource,+ resourceQueueCountRef = queueCountRef,+ resourceQueueCountStatsRef = queueCountStatsRef,+ resourceQueueCountSource = queueCountSource,+ resourceTotalWaitTimeRef = totalWaitTimeRef,+ resourceWaitTimeRef = waitTimeRef,+ resourceWaitTimeSource = waitTimeSource, resourceWaitList = waitList } -- | Return the current available count of the resource.@@ -285,6 +293,46 @@ resourceUtilisationCountChanged_ r = mapSignal (const ()) $ resourceUtilisationCountChanged r +-- | Return the current queue length of the resource.+resourceQueueCount :: Resource s -> Event Int+resourceQueueCount r =+ Event $ \p -> readIORef (resourceQueueCountRef r)++-- | Return the statistics for the queue length of the resource.+resourceQueueCountStats :: Resource s -> Event (TimingStats Int)+resourceQueueCountStats r =+ Event $ \p -> readIORef (resourceQueueCountStatsRef r)++-- | Signal triggered when the 'resourceQueueCount' property changes.+resourceQueueCountChanged :: Resource s -> Signal Int+resourceQueueCountChanged r =+ publishSignal $ resourceQueueCountSource r++-- | Signal triggered when the 'resourceQueueCount' property changes.+resourceQueueCountChanged_ :: Resource s -> Signal ()+resourceQueueCountChanged_ r =+ mapSignal (const ()) $ resourceQueueCountChanged r++-- | Return the total wait time of the resource.+resourceTotalWaitTime :: Resource s -> Event Double+resourceTotalWaitTime r =+ Event $ \p -> readIORef (resourceTotalWaitTimeRef r)++-- | Return the statistics for the wait time of the resource.+resourceWaitTime :: Resource s -> Event (SamplingStats Double)+resourceWaitTime r =+ Event $ \p -> readIORef (resourceWaitTimeRef r)++-- | Signal triggered when the 'resourceTotalWaitTime' and 'resourceWaitTime' properties change.+resourceWaitTimeChanged :: Resource s -> Signal (SamplingStats Double)+resourceWaitTimeChanged r =+ mapSignalM (\() -> resourceWaitTime r) $ resourceWaitTimeChanged_ r++-- | Signal triggered when the 'resourceTotalWaitTime' and 'resourceWaitTime' properties change.+resourceWaitTimeChanged_ :: Resource s -> Signal ()+resourceWaitTimeChanged_ r =+ publishSignal $ resourceWaitTimeSource r+ -- | Request for the resource decreasing its count in case of success, -- otherwise suspending the discontinuous process until some other -- process releases the resource.@@ -304,8 +352,11 @@ invokeProcess pid $ requestResource r invokeEvent p $- strategyEnqueue (resourceWaitList r) c- else do invokeEvent p $ updateResourceCount r (-1)+ strategyEnqueue (resourceWaitList r) $+ ResourceItem (pointTime p) c+ invokeEvent p $ updateResourceQueueCount r 1+ else do invokeEvent p $ updateResourceWaitTime r 0+ invokeEvent p $ updateResourceCount r (-1) invokeEvent p $ updateResourceUtilisationCount r 1 invokeEvent p $ resumeCont c () @@ -330,8 +381,11 @@ invokeProcess pid $ requestResourceWithPriority r priority invokeEvent p $- strategyEnqueueWithPriority (resourceWaitList r) priority c- else do invokeEvent p $ updateResourceCount r (-1)+ strategyEnqueueWithPriority (resourceWaitList r) priority $+ ResourceItem (pointTime p) c+ invokeEvent p $ updateResourceQueueCount r 1+ else do invokeEvent p $ updateResourceWaitTime r 0+ invokeEvent p $ updateResourceCount r (-1) invokeEvent p $ updateResourceUtilisationCount r 1 invokeEvent p $ resumeCont c () @@ -379,14 +433,16 @@ strategyQueueNull (resourceWaitList r) if f then invokeEvent p $ updateResourceCount r 1- else do c <- invokeEvent p $+ else do x <- invokeEvent p $ strategyDequeue (resourceWaitList r)- c <- invokeEvent p $ unfreezeCont c+ invokeEvent p $ updateResourceQueueCount r (-1)+ c <- invokeEvent p $ unfreezeCont (resourceItemCont x) case c of Nothing -> invokeEvent p $ releaseResource' r Just c ->- do invokeEvent p $ updateResourceUtilisationCount r 1+ do invokeEvent p $ updateResourceWaitTime r (pointTime p - resourceItemTime x)+ invokeEvent p $ updateResourceUtilisationCount r 1 invokeEvent p $ enqueueEvent (pointTime p) $ resumeCont c () -- | Try to request for the resource decreasing its count in case of success@@ -399,7 +455,8 @@ do a <- readIORef (resourceCountRef r) if a == 0 then return False- else do invokeEvent p $ updateResourceCount r (-1)+ else do invokeEvent p $ updateResourceWaitTime r 0+ invokeEvent p $ updateResourceCount r (-1) invokeEvent p $ updateResourceUtilisationCount r 1 return True @@ -477,7 +534,8 @@ resourceChanged_ :: Resource s -> Signal () resourceChanged_ r = resourceCountChanged_ r <>- resourceUtilisationCountChanged_ r+ resourceUtilisationCountChanged_ r <>+ resourceQueueCountChanged_ r -- | Update the resource count and its statistics. updateResourceCount :: Resource s -> Int -> Event ()@@ -502,3 +560,27 @@ addTimingStats (pointTime p) a' invokeEvent p $ triggerSignal (resourceUtilisationCountSource r) a'++-- | Update the resource queue length and its statistics.+updateResourceQueueCount :: Resource s -> Int -> Event ()+updateResourceQueueCount r delta =+ Event $ \p ->+ do a <- readIORef (resourceQueueCountRef r)+ let a' = a + delta+ a' `seq` writeIORef (resourceQueueCountRef r) a'+ modifyIORef' (resourceQueueCountStatsRef r) $+ addTimingStats (pointTime p) a'+ invokeEvent p $+ triggerSignal (resourceQueueCountSource r) a'++-- | Update the resource wait time and its statistics.+updateResourceWaitTime :: Resource s -> Double -> Event ()+updateResourceWaitTime r delta =+ Event $ \p ->+ do a <- readIORef (resourceTotalWaitTimeRef r)+ let a' = a + delta+ a' `seq` writeIORef (resourceTotalWaitTimeRef r) a'+ modifyIORef' (resourceWaitTimeRef r) $+ addSamplingStats delta+ invokeEvent p $+ triggerSignal (resourceWaitTimeSource r) ()
Simulation/Aivika/Resource/Preemption.hs view
@@ -21,6 +21,10 @@ resourceCountStats, resourceUtilisationCount, resourceUtilisationCountStats,+ resourceQueueCount,+ resourceQueueCountStats,+ resourceTotalWaitTime,+ resourceWaitTime, -- * Requesting for and Releasing Resource requestResourceWithPriority, releaseResource,@@ -34,6 +38,10 @@ resourceCountChanged_, resourceUtilisationCountChanged, resourceUtilisationCountChanged_,+ resourceQueueCountChanged,+ resourceQueueCountChanged_,+ resourceWaitTimeChanged,+ resourceWaitTimeChanged_, resourceChanged_) where import Data.IORef@@ -65,6 +73,12 @@ resourceUtilisationCountRef :: IORef Int, resourceUtilisationCountStatsRef :: IORef (TimingStats Int), resourceUtilisationCountSource :: SignalSource Int,+ resourceQueueCountRef :: IORef Int,+ resourceQueueCountStatsRef :: IORef (TimingStats Int),+ resourceQueueCountSource :: SignalSource Int,+ resourceTotalWaitTimeRef :: IORef Double,+ resourceWaitTimeRef :: IORef (SamplingStats Double),+ resourceWaitTimeSource :: SignalSource (), resourceActingQueue :: PQ.PriorityQueue ResourceActingItem, resourceWaitQueue :: PQ.PriorityQueue ResourceAwaitingItem } @@ -79,12 +93,14 @@ -- | Idenitifies an item that requests for the resource. data ResourceRequestingItem = ResourceRequestingItem { requestingItemPriority :: Double,+ requestingItemTime :: Double, requestingItemId :: ProcessId, requestingItemCont :: FrozenCont () } -- | Idenitifies an item that was preempted. data ResourcePreemptedItem = ResourcePreemptedItem { preemptedItemPriority :: Double,+ preemptedItemTime :: Double, preemptedItemId :: ProcessId } instance Eq Resource where@@ -98,30 +114,7 @@ -- ^ the initial count (and maximal count too) of the resource -> Event Resource newResource count =- Event $ \p ->- do let r = pointRun p- t = pointTime p- when (count < 0) $- error $- "The resource count cannot be negative: " ++- "newResource."- countRef <- newIORef count- countStatsRef <- newIORef $ returnTimingStats t count- countSource <- invokeSimulation r newSignalSource- utilCountRef <- newIORef 0- utilCountStatsRef <- newIORef $ returnTimingStats t 0- utilCountSource <- invokeSimulation r newSignalSource- actingQueue <- PQ.newQueue- waitQueue <- PQ.newQueue- return Resource { resourceMaxCount = Just count,- resourceCountRef = countRef,- resourceCountStatsRef = countStatsRef,- resourceCountSource = countSource,- resourceUtilisationCountRef = utilCountRef,- resourceUtilisationCountStatsRef = utilCountStatsRef,- resourceUtilisationCountSource = utilCountSource,- resourceActingQueue = actingQueue,- resourceWaitQueue = waitQueue }+ newResourceWithMaxCount count (Just count) -- | Create a new resource with the specified initial and maximum counts, -- where 'Nothing' means that the resource has no upper bound.@@ -151,6 +144,12 @@ utilCountRef <- newIORef 0 utilCountStatsRef <- newIORef $ returnTimingStats t 0 utilCountSource <- invokeSimulation r newSignalSource+ queueCountRef <- newIORef 0+ queueCountStatsRef <- newIORef $ returnTimingStats t 0+ queueCountSource <- invokeSimulation r newSignalSource+ totalWaitTimeRef <- newIORef 0+ waitTimeRef <- newIORef emptySamplingStats+ waitTimeSource <- invokeSimulation r newSignalSource actingQueue <- PQ.newQueue waitQueue <- PQ.newQueue return Resource { resourceMaxCount = maxCount,@@ -160,6 +159,12 @@ resourceUtilisationCountRef = utilCountRef, resourceUtilisationCountStatsRef = utilCountStatsRef, resourceUtilisationCountSource = utilCountSource,+ resourceQueueCountRef = queueCountRef,+ resourceQueueCountStatsRef = queueCountStatsRef,+ resourceQueueCountSource = queueCountSource,+ resourceTotalWaitTimeRef = totalWaitTimeRef,+ resourceWaitTimeRef = waitTimeRef,+ resourceWaitTimeSource = waitTimeSource, resourceActingQueue = actingQueue, resourceWaitQueue = waitQueue } @@ -203,6 +208,46 @@ resourceUtilisationCountChanged_ r = mapSignal (const ()) $ resourceUtilisationCountChanged r +-- | Return the current queue length of the resource.+resourceQueueCount :: Resource -> Event Int+resourceQueueCount r =+ Event $ \p -> readIORef (resourceQueueCountRef r)++-- | Return the statistics for the queue length of the resource.+resourceQueueCountStats :: Resource -> Event (TimingStats Int)+resourceQueueCountStats r =+ Event $ \p -> readIORef (resourceQueueCountStatsRef r)++-- | Signal triggered when the 'resourceQueueCount' property changes.+resourceQueueCountChanged :: Resource -> Signal Int+resourceQueueCountChanged r =+ publishSignal $ resourceQueueCountSource r++-- | Signal triggered when the 'resourceQueueCount' property changes.+resourceQueueCountChanged_ :: Resource -> Signal ()+resourceQueueCountChanged_ r =+ mapSignal (const ()) $ resourceQueueCountChanged r++-- | Return the total wait time of the resource.+resourceTotalWaitTime :: Resource -> Event Double+resourceTotalWaitTime r =+ Event $ \p -> readIORef (resourceTotalWaitTimeRef r)++-- | Return the statistics for the wait time of the resource.+resourceWaitTime :: Resource -> Event (SamplingStats Double)+resourceWaitTime r =+ Event $ \p -> readIORef (resourceWaitTimeRef r)++-- | Signal triggered when the 'resourceTotalWaitTime' and 'resourceWaitTime' properties change.+resourceWaitTimeChanged :: Resource -> Signal (SamplingStats Double)+resourceWaitTimeChanged r =+ mapSignalM (\() -> resourceWaitTime r) $ resourceWaitTimeChanged_ r++-- | Signal triggered when the 'resourceTotalWaitTime' and 'resourceWaitTime' properties change.+resourceWaitTimeChanged_ :: Resource -> Signal ()+resourceWaitTimeChanged_ r =+ publishSignal $ resourceWaitTimeSource r+ -- | Request with the priority for the resource decreasing its count -- in case of success, otherwise suspending the discontinuous process -- until some other process releases the resource.@@ -219,7 +264,8 @@ Process $ \pid -> Cont $ \c -> Event $ \p ->- do a <- readIORef (resourceCountRef r)+ do let t = pointTime p+ a <- readIORef (resourceCountRef r) if a == 0 then do f <- PQ.queueNull (resourceActingQueue r) if f@@ -228,14 +274,16 @@ invokeCont c $ invokeProcess pid $ requestResourceWithPriority r priority- PQ.enqueue (resourceWaitQueue r) priority (Left $ ResourceRequestingItem priority pid c)+ PQ.enqueue (resourceWaitQueue r) priority (Left $ ResourceRequestingItem priority t pid c)+ invokeEvent p $ updateResourceQueueCount r 1 else do (p0', item0) <- PQ.queueFront (resourceActingQueue r) let p0 = - p0' pid0 = actingItemId item0 if priority < p0 then do PQ.dequeue (resourceActingQueue r) PQ.enqueue (resourceActingQueue r) (- priority) $ ResourceActingItem priority pid- PQ.enqueue (resourceWaitQueue r) p0 (Right $ ResourcePreemptedItem p0 pid0)+ PQ.enqueue (resourceWaitQueue r) p0 (Right $ ResourcePreemptedItem p0 t pid0)+ invokeEvent p $ updateResourceQueueCount r 1 invokeEvent p $ processPreemptionBegin pid0 invokeEvent p $ resumeCont c () else do c <- invokeEvent p $@@ -243,8 +291,10 @@ invokeCont c $ invokeProcess pid $ requestResourceWithPriority r priority- PQ.enqueue (resourceWaitQueue r) priority (Left $ ResourceRequestingItem priority pid c)+ PQ.enqueue (resourceWaitQueue r) priority (Left $ ResourceRequestingItem priority t pid c)+ invokeEvent p $ updateResourceQueueCount r 1 else do PQ.enqueue (resourceActingQueue r) (- priority) $ ResourceActingItem priority pid+ invokeEvent p $ updateResourceWaitTime r 0 invokeEvent p $ updateResourceCount r (-1) invokeEvent p $ updateResourceUtilisationCount r 1 invokeEvent p $ resumeCont c ()@@ -287,23 +337,26 @@ then invokeEvent p $ updateResourceCount r 1 else do (priority', item) <- PQ.queueFront (resourceWaitQueue r) PQ.dequeue (resourceWaitQueue r)+ invokeEvent p $ updateResourceQueueCount r (-1) case item of- Left (ResourceRequestingItem priority pid c) ->+ Left (ResourceRequestingItem priority t pid c) -> do c <- invokeEvent p $ unfreezeCont c case c of Nothing -> invokeEvent p $ releaseResource' r Just c -> do PQ.enqueue (resourceActingQueue r) (- priority) $ ResourceActingItem priority pid+ invokeEvent p $ updateResourceWaitTime r (pointTime p - t) invokeEvent p $ updateResourceUtilisationCount r 1 invokeEvent p $ enqueueEvent (pointTime p) $ resumeCont c ()- Right (ResourcePreemptedItem priority pid) ->+ Right (ResourcePreemptedItem priority t pid) -> do f <- invokeEvent p $ processCancelled pid case f of True -> invokeEvent p $ releaseResource' r False -> do PQ.enqueue (resourceActingQueue r) (- priority) $ ResourceActingItem priority pid+ invokeEvent p $ updateResourceWaitTime r (pointTime p - t) invokeEvent p $ updateResourceUtilisationCount r 1 invokeEvent p $ processPreemptionEnd pid @@ -328,7 +381,8 @@ decResourceCount' :: Resource -> Event () decResourceCount' r = Event $ \p ->- do a <- readIORef (resourceCountRef r)+ do let t = pointTime p+ a <- readIORef (resourceCountRef r) when (a == 0) $ error $ "The resource exceeded and its count is zero: decResourceCount'"@@ -338,9 +392,10 @@ let p0 = - p0' pid0 = actingItemId item0 PQ.dequeue (resourceActingQueue r)- PQ.enqueue (resourceWaitQueue r) p0 (Right $ ResourcePreemptedItem p0 pid0)+ PQ.enqueue (resourceWaitQueue r) p0 (Right $ ResourcePreemptedItem p0 t pid0) invokeEvent p $ processPreemptionBegin pid0 invokeEvent p $ updateResourceUtilisationCount r (-1)+ invokeEvent p $ updateResourceQueueCount r 1 invokeEvent p $ updateResourceCount r (-1) -- | Increase the count of available resource by the specified number,@@ -388,7 +443,8 @@ resourceChanged_ :: Resource -> Signal () resourceChanged_ r = resourceCountChanged_ r <>- resourceUtilisationCountChanged_ r+ resourceUtilisationCountChanged_ r <>+ resourceQueueCountChanged_ r -- | Update the resource count and its statistics. updateResourceCount :: Resource -> Int -> Event ()@@ -402,6 +458,18 @@ invokeEvent p $ triggerSignal (resourceCountSource r) a' +-- | Update the resource queue length and its statistics.+updateResourceQueueCount :: Resource -> Int -> Event ()+updateResourceQueueCount r delta =+ Event $ \p ->+ do a <- readIORef (resourceQueueCountRef r)+ let a' = a + delta+ a' `seq` writeIORef (resourceQueueCountRef r) a'+ modifyIORef' (resourceQueueCountStatsRef r) $+ addTimingStats (pointTime p) a'+ invokeEvent p $+ triggerSignal (resourceQueueCountSource r) a'+ -- | Update the resource utilisation count and its statistics. updateResourceUtilisationCount :: Resource -> Int -> Event () updateResourceUtilisationCount r delta =@@ -413,3 +481,15 @@ addTimingStats (pointTime p) a' invokeEvent p $ triggerSignal (resourceUtilisationCountSource r) a'++-- | Update the resource wait time and its statistics.+updateResourceWaitTime :: Resource -> Double -> Event ()+updateResourceWaitTime r delta =+ Event $ \p ->+ do a <- readIORef (resourceTotalWaitTimeRef r)+ let a' = a + delta+ a' `seq` writeIORef (resourceTotalWaitTimeRef r) a'+ modifyIORef' (resourceWaitTimeRef r) $+ addSamplingStats delta+ invokeEvent p $+ triggerSignal (resourceWaitTimeSource r) ()
Simulation/Aivika/Results.hs view
@@ -1755,6 +1755,10 @@ resultObjectSignal = resultContainerSignal c, resultObjectSummary = resourceResultSummary c, resultObjectProperties = [+ resultContainerProperty c "queueCount" ResourceQueueCountId resourceQueueCount resourceQueueCountChanged_,+ resultContainerProperty c "queueCountStats" ResourceQueueCountStatsId resourceQueueCountStats resourceQueueCountChanged_,+ resultContainerProperty c "totalWaitTime" ResourceTotalWaitTimeId resourceTotalWaitTime resourceWaitTimeChanged_,+ resultContainerProperty c "waitTime" ResourceWaitTimeId resourceWaitTime resourceWaitTimeChanged_, resultContainerProperty c "count" ResourceCountId resourceCount resourceCountChanged_, resultContainerProperty c "countStats" ResourceCountStatsId resourceCountStats resourceCountChanged_, resultContainerProperty c "utilisationCount" ResourceUtilisationCountId resourceUtilisationCount resourceUtilisationCountChanged_,@@ -1773,6 +1777,8 @@ resultObjectSignal = resultContainerSignal c, resultObjectSummary = resourceResultSummary c, resultObjectProperties = [+ resultContainerProperty c "queueCountStats" ResourceQueueCountStatsId resourceQueueCountStats resourceQueueCountChanged_,+ resultContainerProperty c "waitTime" ResourceWaitTimeId resourceWaitTime resourceWaitTimeChanged_, resultContainerProperty c "countStats" ResourceCountStatsId resourceCountStats resourceCountChanged_, resultContainerProperty c "utilisationCountStats" ResourceUtilisationCountStatsId resourceUtilisationCountStats resourceUtilisationCountChanged_ ] } @@ -1789,6 +1795,10 @@ resultObjectSignal = resultContainerSignal c, resultObjectSummary = preemptibleResourceResultSummary c, resultObjectProperties = [+ resultContainerProperty c "queueCount" ResourceQueueCountId PR.resourceQueueCount PR.resourceQueueCountChanged_,+ resultContainerProperty c "queueCountStats" ResourceQueueCountStatsId PR.resourceQueueCountStats PR.resourceQueueCountChanged_,+ resultContainerProperty c "totalWaitTime" ResourceTotalWaitTimeId PR.resourceTotalWaitTime PR.resourceWaitTimeChanged_,+ resultContainerProperty c "waitTime" ResourceWaitTimeId PR.resourceWaitTime PR.resourceWaitTimeChanged_, resultContainerProperty c "count" ResourceCountId PR.resourceCount PR.resourceCountChanged_, resultContainerProperty c "countStats" ResourceCountStatsId PR.resourceCountStats PR.resourceCountChanged_, resultContainerProperty c "utilisationCount" ResourceUtilisationCountId PR.resourceUtilisationCount PR.resourceUtilisationCountChanged_,@@ -1807,6 +1817,8 @@ resultObjectSignal = resultContainerSignal c, resultObjectSummary = preemptibleResourceResultSummary c, resultObjectProperties = [+ resultContainerProperty c "queueCountStats" ResourceQueueCountStatsId PR.resourceQueueCountStats PR.resourceQueueCountChanged_,+ resultContainerProperty c "waitTime" ResourceWaitTimeId PR.resourceWaitTime PR.resourceWaitTimeChanged_, resultContainerProperty c "countStats" ResourceCountStatsId PR.resourceCountStats PR.resourceCountChanged_, resultContainerProperty c "utilisationCountStats" ResourceUtilisationCountStatsId PR.resourceUtilisationCountStats PR.resourceUtilisationCountChanged_ ] }
Simulation/Aivika/Results/Locale.hs view
@@ -226,6 +226,14 @@ -- ^ Property 'resourceUtilisationCount'. | ResourceUtilisationCountStatsId -- ^ Property 'resourceUtilisationCountStats'.+ | ResourceQueueCountId+ -- ^ Property 'resourceQueueCount'.+ | ResourceQueueCountStatsId+ -- ^ Property 'resourceQueueCountStats'.+ | ResourceTotalWaitTimeId+ -- ^ Property 'resourceTotalWaitTime'.+ | ResourceWaitTimeId+ -- ^ Property 'resourceWaitTime'. | UserDefinedResultId ResultDescription -- ^ An user defined description. | LocalisedResultId (M.Map ResultLocale ResultDescription)@@ -331,6 +339,10 @@ russianResultLocalisation ResourceCountStatsId = "статистика по доступному количеству ресурса" russianResultLocalisation ResourceUtilisationCountId = "текущее используемое количество ресурса" russianResultLocalisation ResourceUtilisationCountStatsId = "статистика по используемому количеству ресурса"+russianResultLocalisation ResourceQueueCountId = "текущая длина очереди к ресурсу"+russianResultLocalisation ResourceQueueCountStatsId = "статистика длины очереди к ресурсу"+russianResultLocalisation ResourceTotalWaitTimeId = "общее время ожидания ресурса"+russianResultLocalisation ResourceWaitTimeId = "время ожидания ресурса" russianResultLocalisation (UserDefinedResultId m) = m russianResultLocalisation x@(LocalisedResultId m) = lookupResultLocalisation russianResultLocale x@@ -426,6 +438,10 @@ englishResultLocalisation ResourceCountStatsId = "the available count statistics" englishResultLocalisation ResourceUtilisationCountId = "the current utilisation count" englishResultLocalisation ResourceUtilisationCountStatsId = "the utilisation count statistics"+englishResultLocalisation ResourceQueueCountId = "the current queue length"+englishResultLocalisation ResourceQueueCountStatsId = "the queue length statistics"+englishResultLocalisation ResourceTotalWaitTimeId = "the total wait time"+englishResultLocalisation ResourceWaitTimeId = "the wait time" englishResultLocalisation (UserDefinedResultId m) = m englishResultLocalisation x@(LocalisedResultId m) = lookupResultLocalisation englishResultLocale x
aivika.cabal view
@@ -1,5 +1,5 @@ name: aivika-version: 4.1+version: 4.1.1 synopsis: A multi-paradigm simulation library description: Aivika is a multi-paradigm simulation library with a strong emphasis