Skip to content

Commit

Permalink
Use hackage rawlock
Browse files Browse the repository at this point in the history
  • Loading branch information
jasagredo committed Oct 22, 2024
1 parent 25af5a0 commit bb5d108
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 775 deletions.
2 changes: 1 addition & 1 deletion cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repository cardano-haskell-packages
-- update either of these.
index-state:
-- Bump this if you need newer packages from Hackage
, hackage.haskell.org 2024-09-16T12:20:25Z
, hackage.haskell.org 2024-10-22T14:26:27Z
-- Bump this if you need newer packages from CHaP
, cardano-haskell-packages 2024-10-21T06:28:35Z

Expand Down
3 changes: 1 addition & 2 deletions ouroboros-consensus/ouroboros-consensus.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ library
Ouroboros.Consensus.Util.IOLike
Ouroboros.Consensus.Util.LeakyBucket
Ouroboros.Consensus.Util.MonadSTM.NormalForm
Ouroboros.Consensus.Util.MonadSTM.RAWLock
Ouroboros.Consensus.Util.MonadSTM.StrictSVar
Ouroboros.Consensus.Util.NormalForm.StrictMVar
Ouroboros.Consensus.Util.NormalForm.StrictTVar
Expand Down Expand Up @@ -302,6 +301,7 @@ library
primitive,
psqueues ^>=0.2.3,
quiet ^>=0.2,
rawlock ^>=0.1,
reflection,
semialign >=1.1,
serialise ^>=0.2,
Expand Down Expand Up @@ -534,7 +534,6 @@ test-suite consensus-test
Test.Consensus.MiniProtocol.LocalStateQuery.Server
Test.Consensus.ResourceRegistry
Test.Consensus.Util.MonadSTM.NormalForm
Test.Consensus.Util.MonadSTM.RAWLock
Test.Consensus.Util.Versioned

build-depends:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ import qualified Codec.CBOR.Write as CBOR
import Control.Monad (unless, when)
import Control.Monad.State.Strict (get, gets, lift, modify, put,
state)
import qualified Control.RAWLock as RAWLock
import Control.Tracer (Tracer, nullTracer, traceWith)
import qualified Data.ByteString.Lazy as Lazy
import Data.List as List (foldl')
Expand All @@ -141,7 +142,6 @@ import Ouroboros.Consensus.Storage.VolatileDB.Impl.Types
import Ouroboros.Consensus.Storage.VolatileDB.Impl.Util
import Ouroboros.Consensus.Util.Args
import Ouroboros.Consensus.Util.IOLike
import qualified Ouroboros.Consensus.Util.MonadSTM.RAWLock as RAWLock
import Ouroboros.Consensus.Util.ResourceRegistry
import Ouroboros.Network.Block (MaxSlotNo (..))
import System.FS.API.Lazy
Expand Down Expand Up @@ -233,7 +233,7 @@ closeDBImpl ::
-> m ()
closeDBImpl VolatileDBEnv { varInternalState, tracer, hasFS } = do
mbInternalState <-
RAWLock.withWriteAccess varInternalState $ \st -> return (DbClosed, st)
RAWLock.withWriteAccess varInternalState $ \st -> return (st, DbClosed)
case mbInternalState of
DbClosed -> traceWith tracer DBAlreadyClosed
DbOpen ost -> do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ module Ouroboros.Consensus.Storage.VolatileDB.Impl.State (

import Control.Monad
import Control.Monad.State.Strict hiding (withState)
import Control.RAWLock (RAWLock)
import qualified Control.RAWLock as RAWLock
import Control.Tracer (Tracer, traceWith)
import qualified Data.ByteString.Lazy as Lazy
import Data.List as List (foldl')
Expand All @@ -52,10 +54,8 @@ import qualified Ouroboros.Consensus.Storage.VolatileDB.Impl.Index as Index
import Ouroboros.Consensus.Storage.VolatileDB.Impl.Parser
import Ouroboros.Consensus.Storage.VolatileDB.Impl.Types
import Ouroboros.Consensus.Storage.VolatileDB.Impl.Util
import Ouroboros.Consensus.Util (whenJust, (.:))
import Ouroboros.Consensus.Util (whenJust)
import Ouroboros.Consensus.Util.IOLike
import Ouroboros.Consensus.Util.MonadSTM.RAWLock (RAWLock)
import qualified Ouroboros.Consensus.Util.MonadSTM.RAWLock as RAWLock
import Ouroboros.Consensus.Util.ResourceRegistry (WithTempRegistry,
allocateTemp, modifyWithTempRegistry)
import Ouroboros.Network.Block (MaxSlotNo (..))
Expand Down Expand Up @@ -135,8 +135,7 @@ modifyOpenState appendOrWrite
-- temporary registry.
(acquire, release) = case appendOrWrite of
Append ->
(atomically . RAWLock.unsafeAcquireAppendAccess,
atomically .: RAWLock.unsafeReleaseAppendAccess)
(RAWLock.unsafeAcquireAppendAccess, RAWLock.unsafeReleaseAppendAccess)
Write ->
(RAWLock.unsafeAcquireWriteAccess, RAWLock.unsafeReleaseWriteAccess)

Expand Down
Loading

0 comments on commit bb5d108

Please sign in to comment.