packages feed

aivika 4.3.2 → 4.3.3

raw patch · 7 files changed

+72/−4 lines, 7 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Simulation.Aivika.QueueStrategy: data family StrategyQueue s :: * -> *;
- Simulation.Aivika.QueueStrategy: }
- Simulation.Aivika.Statistics: instance (Simulation.Aivika.Statistics.TimingData a, GHC.Show.Show a) => GHC.Show.Show (Simulation.Aivika.Statistics.TimingCounter a)
+ Simulation.Aivika.Statistics: instance (GHC.Show.Show a, Simulation.Aivika.Statistics.TimingData a) => GHC.Show.Show (Simulation.Aivika.Statistics.TimingCounter a)
+ Simulation.Aivika.Vector: vectorDeleteRange :: Vector a -> Int -> Int -> IO ()
+ Simulation.Aivika.Vector.Unboxed: vectorDeleteRange :: Unboxed a => Vector a -> Int -> Int -> IO ()
- Simulation.Aivika.QueueStrategy: class QueueStrategy s where data StrategyQueue s :: * -> * where {
+ Simulation.Aivika.QueueStrategy: class QueueStrategy s where data family StrategyQueue s :: * -> *

Files

CHANGELOG.md view
@@ -1,3 +1,12 @@++Version 4.3.3+-----++* Added function vectorDeleteRange to remove the range of elements from the mutable vector.++* Fixed the resource preemption when releasing and requesting again for the resource at+  the same modeling time.+ Version 4.3.2 ----- 
Simulation/Aivika/Internal/Cont.hs view
@@ -820,7 +820,7 @@                        ContPreemptionEnding ->                          invokeEvent p $                          enqueueEvent (pointTime p) $-                         resumeCont c a+                         reenterCont c a                        ContPreemptionBeginning ->                          error "The computation was already preempted: sleepCont."      writeIORef rh (Just h)
Simulation/Aivika/Resource/Preemption.hs view
@@ -349,7 +349,7 @@                           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 ()+                             invokeEvent p $ enqueueEvent (pointTime p) $ reenterCont c ()                  Right (ResourcePreemptedItem priority t pid) ->                    do f <- invokeEvent p $ processCancelled pid                       case f of
Simulation/Aivika/Resource/Preemption/Base.hs view
@@ -223,7 +223,7 @@                           invokeEvent p $ releaseResource' r                         Just c ->                           do PQ.enqueue (resourceActingQueue r) (- priority) $ ResourceActingItem priority pid-                             invokeEvent p $ enqueueEvent (pointTime p) $ resumeCont c ()+                             invokeEvent p $ enqueueEvent (pointTime p) $ reenterCont c ()                  Right (ResourcePreemptedItem priority pid) ->                    do f <- invokeEvent p $ processCancelled pid                       case f of
Simulation/Aivika/Vector.hs view
@@ -22,6 +22,7 @@         vectorBinarySearch,         vectorInsert,         vectorDeleteAt,+        vectorDeleteRange,         vectorDelete,         vectorDeleteBy,         vectorIndex,@@ -174,6 +175,34 @@           writeArray array i x      writeArray array (count - 1) undefined      writeIORef (vectorCountRef vector) (count - 1)++-- | Delete the specified range of elements.+vectorDeleteRange :: Vector a+                     -- ^ the vector+                     -> Int+                     -- ^ the start index+                     -> Int+                     -- ^ the count of items to be removed+                     -> IO ()+vectorDeleteRange vector index len =+  do count <- readIORef (vectorCountRef vector)+     when (index < 0) $+       error $+       "The first index cannot be " +++       "negative: vectorDeleteRange."+     when (index + len - 1 >= count) $+       error $+       "The last index must be less " +++       "than the count: vectorDeleteRange."+     when (len < 0) $+       error "Negative range length: vectorDeleteRange." +     array <- readIORef (vectorArrayRef vector)+     forM_ [index, index + 1 .. (count - len) - 1] $ \i ->+       do x <- readArray array (i + len)+          writeArray array i x+     forM_ [(count - len) .. count - 1] $ \i ->+       writeArray array i undefined+     writeIORef (vectorCountRef vector) (count - len)       -- | Return the index of the item or -1.      vectorIndex :: Eq a => Vector a -> a -> IO Int
Simulation/Aivika/Vector/Unboxed.hs view
@@ -22,6 +22,7 @@         vectorBinarySearch,         vectorInsert,         vectorDeleteAt,+        vectorDeleteRange,         vectorDelete,         vectorDeleteBy,         vectorIndex,@@ -176,6 +177,35 @@           writeArray array i x      writeArray array (count - 1) undefined      writeIORef (vectorCountRef vector) (count - 1)++-- | Delete the specified range of elements.+vectorDeleteRange :: Unboxed a+                     => Vector a+                     -- ^ the vector+                     -> Int+                     -- ^ the start index+                     -> Int+                     -- ^ the count of items to be removed+                     -> IO ()+vectorDeleteRange vector index len =+  do count <- readIORef (vectorCountRef vector)+     when (index < 0) $+       error $+       "The first index cannot be " +++       "negative: vectorDeleteRange."+     when (index + len - 1 >= count) $+       error $+       "The last index must be less " +++       "than the count: vectorDeleteRange."+     when (len < 0) $+       error "Negative range length: vectorDeleteRange." +     array <- readIORef (vectorArrayRef vector)+     forM_ [index, index + 1 .. (count - len) - 1] $ \i ->+       do x <- readArray array (i + len)+          writeArray array i x+     forM_ [(count - len) .. count - 1] $ \i ->+       writeArray array i undefined+     writeIORef (vectorCountRef vector) (count - len)       -- | Return the index of the item or -1.      vectorIndex :: (Unboxed a, Eq a) => Vector a -> a -> IO Int
aivika.cabal view
@@ -1,5 +1,5 @@ name:            aivika-version:         4.3.2+version:         4.3.3 synopsis:        A multi-paradigm simulation library description:     Aivika is a multi-paradigm simulation library with a strong emphasis