ouroboros-consensus-0.1.0.0: Consensus layer for the Ouroboros blockchain protocol
Safe HaskellNone
LanguageHaskell2010

Ouroboros.Consensus.Util.STM

Synopsis

Misc

blockUntilChanged :: forall stm a b. (MonadSTMTx stm, Eq b) => (a -> b) -> b -> stm a -> stm (a, b) Source #

Wait until the TVar changed

onEachChange Source #

Arguments

:: forall m a b. (IOLike m, Eq b, HasCallStack) 
=> ResourceRegistry m 
-> String

Label for the thread

-> (a -> b)

Obtain a fingerprint

-> Maybe b

Optional initial fingerprint If Nothing, the action is executed once immediately to obtain the initial fingerprint.

-> STM m a 
-> (a -> m ()) 
-> m (Thread m Void) 

Spawn a new thread that runs an action each time an STM value changes.

NOTE: STM does not guarantee that onEachChange will literally be called on every change: when the system is under heavy load, some updates may be missed.

The thread will be linked to the registry.

runWhenJust Source #

Arguments

:: IOLike m 
=> ResourceRegistry m 
-> String

Label for the thread

-> STM m (Maybe a) 
-> (a -> m ()) 
-> m () 

Spawn a new thread that waits for an STM value to become Just

The thread will be linked to the registry.

blockUntilJust :: MonadSTMTx stm => stm (Maybe a) -> stm a Source #

blockUntilAllJust :: MonadSTMTx stm => [stm (Maybe a)] -> stm [a] Source #

newtype Fingerprint Source #

Simple type that can be used to indicate something in a TVar is changed.

Constructors

Fingerprint Word64 

Instances

Instances details
Enum Fingerprint Source # 
Instance details

Defined in Ouroboros.Consensus.Util.STM

Eq Fingerprint Source # 
Instance details

Defined in Ouroboros.Consensus.Util.STM

Show Fingerprint Source # 
Instance details

Defined in Ouroboros.Consensus.Util.STM

Generic Fingerprint Source # 
Instance details

Defined in Ouroboros.Consensus.Util.STM

Associated Types

type Rep Fingerprint :: Type -> Type #

NoThunks Fingerprint Source # 
Instance details

Defined in Ouroboros.Consensus.Util.STM

type Rep Fingerprint Source # 
Instance details

Defined in Ouroboros.Consensus.Util.STM

type Rep Fingerprint = D1 ('MetaData "Fingerprint" "Ouroboros.Consensus.Util.STM" "ouroboros-consensus-0.1.0.0-GfJNvFcM6lj2s5utKAUPEp" 'True) (C1 ('MetaCons "Fingerprint" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64)))

data WithFingerprint a Source #

Store a value together with its fingerprint.

Instances

Instances details
Functor WithFingerprint Source # 
Instance details

Defined in Ouroboros.Consensus.Util.STM

Methods

fmap :: (a -> b) -> WithFingerprint a -> WithFingerprint b #

(<$) :: a -> WithFingerprint b -> WithFingerprint a #

Eq a => Eq (WithFingerprint a) Source # 
Instance details

Defined in Ouroboros.Consensus.Util.STM

Show a => Show (WithFingerprint a) Source # 
Instance details

Defined in Ouroboros.Consensus.Util.STM

Generic (WithFingerprint a) Source # 
Instance details

Defined in Ouroboros.Consensus.Util.STM

Associated Types

type Rep (WithFingerprint a) :: Type -> Type #

NoThunks a => NoThunks (WithFingerprint a) Source # 
Instance details

Defined in Ouroboros.Consensus.Util.STM

type Rep (WithFingerprint a) Source # 
Instance details

Defined in Ouroboros.Consensus.Util.STM

type Rep (WithFingerprint a) = D1 ('MetaData "WithFingerprint" "Ouroboros.Consensus.Util.STM" "ouroboros-consensus-0.1.0.0-GfJNvFcM6lj2s5utKAUPEp" 'False) (C1 ('MetaCons "WithFingerprint" 'PrefixI 'True) (S1 ('MetaSel ('Just "forgetFingerprint") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a) :*: S1 ('MetaSel ('Just "getFingerprint") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Fingerprint)))

Simulate various monad stacks in STM

newtype Sim n m Source #

Constructors

Sim 

Fields

simId :: Sim (STM m) m Source #

simStateT :: IOLike m => StrictTVar m st -> Sim n m -> Sim (StateT st n) m Source #