packages feed

aivika 4.3.3 → 4.3.4

raw patch · 13 files changed

+96/−32 lines, 13 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Simulation.Aivika.Statistics: instance (GHC.Show.Show a, Simulation.Aivika.Statistics.TimingData a) => GHC.Show.Show (Simulation.Aivika.Statistics.TimingCounter a)
+ Simulation.Aivika.Event: retryEvent :: String -> Event a
+ Simulation.Aivika.Process: retryProcess :: String -> Process a
+ Simulation.Aivika.QueueStrategy: data family StrategyQueue s :: * -> *;
+ Simulation.Aivika.QueueStrategy: }
+ Simulation.Aivika.Simulation: SimulationRetry :: String -> SimulationRetry
+ Simulation.Aivika.Simulation: data SimulationRetry
+ Simulation.Aivika.Statistics: instance (Simulation.Aivika.Statistics.TimingData a, GHC.Show.Show a) => GHC.Show.Show (Simulation.Aivika.Statistics.TimingCounter a)
- Simulation.Aivika.QueueStrategy: class QueueStrategy s where data family StrategyQueue s :: * -> *
+ Simulation.Aivika.QueueStrategy: class QueueStrategy s where data StrategyQueue s :: * -> * where {
- Simulation.Aivika.Simulation: SimulationAbort :: SimulationAbort
+ Simulation.Aivika.Simulation: SimulationAbort :: String -> SimulationAbort

Files

CHANGELOG.md view
@@ -1,4 +1,11 @@ +Version 4.3.4+-----++* Yet more safe the resource preemption.++* Introducing exception SimulationRetry, which is needed for parallel distributed simulation.+ Version 4.3.3 ----- 
Simulation/Aivika/Event.hs view
@@ -46,6 +46,8 @@         memoEventInTime,         -- * Disposable         DisposableEvent(..),+        -- * Retrying Computation+        retryEvent,         -- * Debugging         traceEvent) where 
Simulation/Aivika/Internal/Cont.hs view
@@ -790,7 +790,15 @@      if not f        then invokeEvent p $             enqueueEvent (pointTime p) $-            resumeCont c a+            Event $ \p ->+            do f <- invokeEvent p $+                    contPreemptionBegun $+                    contId $ contAux c+               if not f+                 then invokeEvent p $+                      resumeCont c a+                 else invokeEvent p $+                      sleepCont c a        else invokeEvent p $             sleepCont c a 
Simulation/Aivika/Internal/Event.hs view
@@ -52,6 +52,8 @@         memoEventInTime,         -- * Disposable         DisposableEvent(..),+        -- * Retrying Computation+        retryEvent,         -- * Debugging         traceEvent) where @@ -409,6 +411,11 @@    mempty = DisposableEvent $ return ()   mappend (DisposableEvent x) (DisposableEvent y) = DisposableEvent $ x >> y++-- | Retry the current computation as possible, using the specified argument+-- as a 'SimulationRetry' exception message in case of failure.+retryEvent :: String -> Event a+retryEvent message = throwEvent $ SimulationRetry message  -- | Show the debug message with the current simulation time. traceEvent :: String -> Event a -> Event a
Simulation/Aivika/Internal/Process.hs view
@@ -88,6 +88,8 @@         memoProcess,         -- * Never Ending Process         neverProcess,+        -- * Retrying Computation+        retryProcess,         -- * Debugging         traceProcess) where @@ -716,6 +718,11 @@   let signal = processCancelling pid   in handleSignal_ signal $ \_ ->      resumeCont c $ error "It must never be computed: neverProcess"++-- | Retry the current computation as possible, using the specified argument+-- as a 'SimulationRetry' exception message in case of failure.+retryProcess :: String -> Process a+retryProcess = liftEvent . retryEvent  -- | Show the debug message with the current simulation time. traceProcess :: String -> Process a -> Process a
Simulation/Aivika/Internal/Simulation.hs view
@@ -32,7 +32,8 @@         memoSimulation,         -- * Exceptions         SimulationException(..),-        SimulationAbort(..)) where+        SimulationAbort(..),+        SimulationRetry(..)) where  import Control.Exception import Control.Monad@@ -197,11 +198,22 @@ instance Exception SimulationException  -- | An exception that signals of aborting the simulation.-data SimulationAbort = SimulationAbort+data SimulationAbort = SimulationAbort String                        -- ^ The exception to abort the simulation.                      deriving (Show, Typeable) +-- | An exception that signals that the current computation should be retried+-- as possible, which feature may be supported by the simulation engine or not.+data SimulationRetry = SimulationRetry String+                       -- ^ The exception to retry the computation.+                     deriving (Show, Typeable)+ instance Exception SimulationAbort where+  +  toException = toException . SimulationException+  fromException x = do { SimulationException a <- fromException x; cast a }++instance Exception SimulationRetry where      toException = toException . SimulationException   fromException x = do { SimulationException a <- fromException x; cast a }
Simulation/Aivika/Process.hs view
@@ -83,6 +83,8 @@         memoProcess,         -- * Never Ending Process         neverProcess,+        -- * Retrying Computation+        retryProcess,         -- * Debugging         traceProcess) where 
Simulation/Aivika/Resource.hs view
@@ -214,12 +214,14 @@   do let r = pointRun p          t = pointTime p      when (count < 0) $-       error $+       throwIO $+       SimulationRetry $        "The resource count cannot be negative: " ++        "newResourceWithMaxCount."      case maxCount of        Just maxCount | count > maxCount ->-         error $+         throwIO $+         SimulationRetry $          "The resource count cannot be greater than " ++          "its maximum value: newResourceWithMaxCount."        _ ->@@ -424,7 +426,8 @@      let a' = a + 1      case resourceMaxCount r of        Just maxCount | a' > maxCount ->-         error $+         throwIO $+         SimulationRetry $          "The resource count cannot be greater than " ++          "its maximum value: releaseResource'."        _ ->@@ -509,7 +512,7 @@                     -- ^ the increment for the resource count                     -> Event () incResourceCount r n-  | n < 0     = error "The increment cannot be negative: incResourceCount"+  | n < 0     = throwEvent $ SimulationRetry "The increment cannot be negative: incResourceCount"   | n == 0    = return ()   | otherwise =     do releaseResource' r@@ -524,7 +527,7 @@                     -- ^ the decrement for the resource count                     -> Process () decResourceCount r n-  | n < 0     = error "The decrement cannot be negative: decResourceCount"+  | n < 0     = throwProcess $ SimulationRetry "The decrement cannot be negative: decResourceCount"   | n == 0    = return ()   | otherwise =     do decResourceCount' r
Simulation/Aivika/Resource/Base.hs view
@@ -167,7 +167,8 @@ newResource s count =   Simulation $ \r ->   do when (count < 0) $-       error $+       throwIO $+       SimulationRetry $        "The resource count cannot be negative: " ++        "newResource."      countRef <- newIORef count@@ -190,12 +191,14 @@ newResourceWithMaxCount s count maxCount =   Simulation $ \r ->   do when (count < 0) $-       error $+       throwIO $+       SimulationRetry $        "The resource count cannot be negative: " ++        "newResourceWithMaxCount."      case maxCount of        Just maxCount | count > maxCount ->-         error $+         throwIO $+         SimulationRetry $          "The resource count cannot be greater than " ++          "its maximum value: newResourceWithMaxCount."        _ ->@@ -287,7 +290,8 @@      let a' = a + 1      case resourceMaxCount r of        Just maxCount | a' > maxCount ->-         error $+         throwIO $+         SimulationRetry $          "The resource count cannot be greater than " ++          "its maximum value: releaseResourceWithinEvent."        _ ->@@ -358,7 +362,7 @@                     -- ^ the increment for the resource count                     -> Event () incResourceCount r n-  | n < 0     = error "The increment cannot be negative: incResourceCount"+  | n < 0     = throwEvent $ SimulationRetry "The increment cannot be negative: incResourceCount"   | n == 0    = return ()   | otherwise =     do releaseResourceWithinEvent r@@ -373,7 +377,7 @@                     -- ^ the decrement for the resource count                     -> Process () decResourceCount r n-  | n < 0     = error "The decrement cannot be negative: decResourceCount"+  | n < 0     = throwProcess $ SimulationRetry "The decrement cannot be negative: decResourceCount"   | n == 0    = return ()   | otherwise =     do requestResource r
Simulation/Aivika/Resource/Preemption.hs view
@@ -129,12 +129,14 @@   do let r = pointRun p          t = pointTime p      when (count < 0) $-       error $+       throwIO $+       SimulationRetry $        "The resource count cannot be negative: " ++        "newResourceWithMaxCount."      case maxCount of        Just maxCount | count > maxCount ->-         error $+         throwIO $+         SimulationRetry $          "The resource count cannot be greater than " ++          "its maximum value: newResourceWithMaxCount."        _ ->@@ -314,7 +316,8 @@        then do invokeEvent p $ updateResourceUtilisationCount r (-1)                invokeEvent p $ releaseResource' r                invokeEvent p $ resumeCont c ()-       else error $+       else throwIO $+            SimulationRetry             "The resource was not acquired by this process: releaseResource"  -- | Release the resource increasing its count and resuming one of the@@ -328,7 +331,8 @@      let a' = a + 1      case resourceMaxCount r of        Just maxCount | a' > maxCount ->-         error $+         throwIO $+         SimulationRetry $          "The resource count cannot be greater than " ++          "its maximum value: releaseResource'."        _ ->@@ -385,7 +389,8 @@   do let t = pointTime p      a <- readIORef (resourceCountRef r)      when (a == 0) $-       error $+       throwIO $+       SimulationRetry        "The resource exceeded and its count is zero: decResourceCount'"      f <- PQ.queueNull (resourceActingQueue r)      unless f $@@ -408,7 +413,7 @@                     -- ^ the increment for the resource count                     -> Event () incResourceCount r n-  | n < 0     = error "The increment cannot be negative: incResourceCount"+  | n < 0     = throwEvent $ SimulationRetry "The increment cannot be negative: incResourceCount"   | n == 0    = return ()   | otherwise =     do releaseResource' r@@ -422,7 +427,7 @@                     -- ^ the decrement for the resource count                     -> Event () decResourceCount r n-  | n < 0     = error "The decrement cannot be negative: decResourceCount"+  | n < 0     = throwEvent $ SimulationRetry "The decrement cannot be negative: decResourceCount"   | n == 0    = return ()   | otherwise =     do decResourceCount' r
Simulation/Aivika/Resource/Preemption/Base.hs view
@@ -88,7 +88,8 @@ newResource count =   Simulation $ \r ->   do when (count < 0) $-       error $+       throwIO $+       SimulationRetry $        "The resource count cannot be negative: " ++        "newResource."      countRef <- newIORef count@@ -109,12 +110,14 @@ newResourceWithMaxCount count maxCount =   Simulation $ \r ->   do when (count < 0) $-       error $+       throwIO $+       SimulationRetry $        "The resource count cannot be negative: " ++        "newResourceWithMaxCount."      case maxCount of        Just maxCount | count > maxCount ->-         error $+         throwIO $+         SimulationRetry $          "The resource count cannot be greater than " ++          "its maximum value: newResourceWithMaxCount."        _ ->@@ -191,7 +194,8 @@      if f        then do invokeEvent p $ releaseResource' r                invokeEvent p $ resumeCont c ()-       else error $+       else throwIO $+            SimulationRetry             "The resource was not acquired by this process: releaseResource"  -- | Release the resource increasing its count and resuming one of the@@ -205,7 +209,8 @@      let a' = a + 1      case resourceMaxCount r of        Just maxCount | a' > maxCount ->-         error $+         throwIO $+         SimulationRetry $          "The resource count cannot be greater than " ++          "its maximum value: releaseResource'."        _ ->@@ -256,7 +261,8 @@   Event $ \p ->   do a <- readIORef (resourceCountRef r)      when (a == 0) $-       error $+       throwIO $+       SimulationRetry        "The resource exceeded and its count is zero: decResourceCount'"      f <- PQ.queueNull (resourceActingQueue r)      unless f $@@ -278,7 +284,7 @@                     -- ^ the increment for the resource count                     -> Event () incResourceCount r n-  | n < 0     = error "The increment cannot be negative: incResourceCount"+  | n < 0     = throwEvent $ SimulationRetry "The increment cannot be negative: incResourceCount"   | n == 0    = return ()   | otherwise =     do releaseResource' r@@ -292,7 +298,7 @@                     -- ^ the decrement for the resource count                     -> Event () decResourceCount r n-  | n < 0     = error "The decrement cannot be negative: decResourceCount"+  | n < 0     = throwEvent $ SimulationRetry "The decrement cannot be negative: decResourceCount"   | n == 0    = return ()   | otherwise =     do decResourceCount' r
Simulation/Aivika/Simulation.hs view
@@ -25,6 +25,7 @@         memoSimulation,         -- * Exceptions         SimulationException(..),-        SimulationAbort(..)) where+        SimulationAbort(..),+        SimulationRetry(..)) where  import Simulation.Aivika.Internal.Simulation
aivika.cabal view
@@ -1,5 +1,5 @@ name:            aivika-version:         4.3.3+version:         4.3.4 synopsis:        A multi-paradigm simulation library description:     Aivika is a multi-paradigm simulation library with a strong emphasis@@ -91,7 +91,7 @@ category:        Simulation license:         BSD3 license-file:    LICENSE-copyright:       (c) 2009-2015. David Sorokin <david.sorokin@gmail.com>+copyright:       (c) 2009-2016. David Sorokin <david.sorokin@gmail.com> author:          David Sorokin maintainer:      David Sorokin <david.sorokin@gmail.com> homepage:        http://www.aivikasoft.com/en/products/aivika.html