Skip to content

Commit e057c08

Browse files
authored
Merge pull request #510 from IntersectMBO/jdral/replace-registry
Use `ActionRegistry` instead of `TempRegistry` everywhere
2 parents 67123cd + 2c7a183 commit e057c08

File tree

9 files changed

+158
-379
lines changed

9 files changed

+158
-379
lines changed

lsm-tree.cabal

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -848,16 +848,13 @@ library control
848848
Control.ActionRegistry
849849
Control.Concurrent.Class.MonadSTM.RWVar
850850
Control.RefCount
851-
Control.TempRegistry
852851

853852
build-depends:
854-
, base >=4.14 && <4.22
855-
, containers ^>=0.6 || ^>=0.7
856-
, deepseq ^>=1.4 || ^>=1.5
857-
, io-classes ^>=1.6 || ^>=1.7
858-
, io-classes:strict-mvar
853+
, base >=4.14 && <4.22
854+
, deepseq ^>=1.4 || ^>=1.5
855+
, io-classes ^>=1.6 || ^>=1.7
859856
, io-classes:strict-stm
860-
, primitive ^>=0.9
857+
, primitive ^>=0.9
861858

862859
test-suite control-test
863860
import: language, warnings

src-control/Control/ActionRegistry.hs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ import Data.List.NonEmpty (NonEmpty (..))
3434
import qualified Data.List.NonEmpty as NE
3535
import 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
249250
unsafeCommitActionRegistry :: (PrimMonad m, MonadCatch m) => ActionRegistry m -> m ()
250251
unsafeCommitActionRegistry 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)

src-control/Control/TempRegistry.hs

Lines changed: 0 additions & 226 deletions
This file was deleted.

0 commit comments

Comments
 (0)