@@ -34,8 +34,6 @@ import Data.List.NonEmpty (NonEmpty (..))
3434import qualified Data.List.NonEmpty as NE
3535import Data.Primitive.MutVar
3636
37- -- TODO: replace TempRegistry by ActionRegistry
38-
3937-- TODO: add tests using fs-sim/io-sim to make sure exception safety is
4038-- guaranteed.
4139
@@ -144,9 +142,12 @@ modifyWithActionRegistry_ getSt putSt action =
144142 can register delayed (commit) and rollback actions. The delayed actions are
145143 all executed at the end if the transaction scope is exited successfully, but
146144 if an exception is thrown (sync or async) then the rollback actions are
147- executed instead, and the exception is propagated. Delay or rollback actions
148- are executed in the reverse order in which they were registered, which is the
149- natural nesting order when considered as bracketing.
145+ executed instead, and the exception is propagated.
146+
147+ * Rollback actions are executed in the reverse order in which they were
148+ registered, which is the natural nesting order when considered as bracketing.
149+
150+ * Delayed actions are executed in the same order in which they are registered.
150151-}
151152
152153-- | Registry of monadic actions supporting rollback actions and delayed actions
@@ -249,8 +250,8 @@ unsafeFinaliseActionRegistry reg ec = case ec of
249250unsafeCommitActionRegistry :: (PrimMonad m , MonadCatch m ) => ActionRegistry m -> m ()
250251unsafeCommitActionRegistry reg = do
251252 as <- readMutVar (registryDelay reg)
252- -- Run actions in LIFO order
253- r <- runActions as
253+ -- Run actions in FIFO order
254+ r <- runActions ( reverse as)
254255 case NE. nonEmpty r of
255256 Nothing -> pure ()
256257 Just exceptions -> throwIO (CommitActionRegistryError exceptions)
0 commit comments