Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ActionRegistry instead of TempRegistry everywhere #510

Merged
merged 4 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions lsm-tree.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -848,16 +848,13 @@ library control
Control.ActionRegistry
Control.Concurrent.Class.MonadSTM.RWVar
Control.RefCount
Control.TempRegistry

build-depends:
, base >=4.14 && <4.22
, containers ^>=0.6 || ^>=0.7
, deepseq ^>=1.4 || ^>=1.5
, io-classes ^>=1.6 || ^>=1.7
, io-classes:strict-mvar
, base >=4.14 && <4.22
, deepseq ^>=1.4 || ^>=1.5
, io-classes ^>=1.6 || ^>=1.7
, io-classes:strict-stm
, primitive ^>=0.9
, primitive ^>=0.9

test-suite control-test
import: language, warnings
Expand Down
15 changes: 8 additions & 7 deletions src-control/Control/ActionRegistry.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ import Data.List.NonEmpty (NonEmpty (..))
import qualified Data.List.NonEmpty as NE
import Data.Primitive.MutVar

-- TODO: replace TempRegistry by ActionRegistry

-- TODO: add tests using fs-sim/io-sim to make sure exception safety is
-- guaranteed.

Expand Down Expand Up @@ -144,9 +142,12 @@ modifyWithActionRegistry_ getSt putSt action =
can register delayed (commit) and rollback actions. The delayed actions are
all executed at the end if the transaction scope is exited successfully, but
if an exception is thrown (sync or async) then the rollback actions are
executed instead, and the exception is propagated. Delay or rollback actions
are executed in the reverse order in which they were registered, which is the
natural nesting order when considered as bracketing.
executed instead, and the exception is propagated.

* Rollback actions are executed in the reverse order in which they were
registered, which is the natural nesting order when considered as bracketing.

* Delayed actions are executed in the same order in which they are registered.
-}

-- | Registry of monadic actions supporting rollback actions and delayed actions
Expand Down Expand Up @@ -249,8 +250,8 @@ unsafeFinaliseActionRegistry reg ec = case ec of
unsafeCommitActionRegistry :: (PrimMonad m, MonadCatch m) => ActionRegistry m -> m ()
unsafeCommitActionRegistry reg = do
as <- readMutVar (registryDelay reg)
-- Run actions in LIFO order
r <- runActions as
-- Run actions in FIFO order
r <- runActions (reverse as)
jorisdral marked this conversation as resolved.
Show resolved Hide resolved
case NE.nonEmpty r of
Nothing -> pure ()
Just exceptions -> throwIO (CommitActionRegistryError exceptions)
Expand Down
226 changes: 0 additions & 226 deletions src-control/Control/TempRegistry.hs

This file was deleted.

Loading
Loading