Safe Haskell | None |
---|---|
Language | Haskell2010 |
Ouroboros.Consensus.Util.STM
Synopsis
- data Watcher (m ∷ Type → Type) a fp = Watcher {}
- forkLinkedWatcher ∷ ∀ m a fp. (IOLike m, Eq fp, HasCallStack) ⇒ ResourceRegistry m → String → Watcher m a fp → m (Thread m Void)
- withWatcher ∷ ∀ m a fp r. (IOLike m, Eq fp, HasCallStack) ⇒ String → Watcher m a fp → m r → m r
- newtype Fingerprint = Fingerprint Word64
- data WithFingerprint a = WithFingerprint {}
- blockUntilAllJust ∷ ∀ (m ∷ Type → Type) a. MonadSTM m ⇒ [STM m (Maybe a)] → STM m [a]
- blockUntilChanged ∷ ∀ (m ∷ Type → Type) a b. (MonadSTM m, Eq b) ⇒ (a → b) → b → STM m a → STM m (a, b)
- blockUntilJust ∷ ∀ (m ∷ Type → Type) a. MonadSTM m ⇒ STM m (Maybe a) → STM m a
- runWhenJust ∷ IOLike m ⇒ ResourceRegistry m → String → STM m (Maybe a) → (a → m ()) → m ()
- newtype Sim (n ∷ Type → Type) (m ∷ Type → Type) = Sim {}
- simId ∷ ∀ (m ∷ Type → Type). Sim (STM m) m
- simStateT ∷ ∀ (m ∷ Type → Type) st (n ∷ Type → Type). IOLike m ⇒ StrictTVar m st → Sim n m → Sim (StateT st n) m
- withTMVar ∷ IOLike m ⇒ StrictTMVar m a → (a → m (c, a)) → m c
- withTMVarAnd ∷ IOLike m ⇒ StrictTMVar m a → (a → STM m b) → (a → b → m (c, a)) → m c
Watcher
data Watcher (m ∷ Type → Type) a fp Source #
Specification for a thread that watches a variable, and reports interesting changes.
NOTE: STM does not guarantee that wNotify
will literally be called on
every change: when the system is under heavy load, some updates may be
missed.
Constructors
Watcher | |
Fields
|
Arguments
∷ ∀ m a fp. (IOLike m, Eq fp, HasCallStack) | |
⇒ ResourceRegistry m | |
→ String | Label for the thread |
→ Watcher m a fp | |
→ m (Thread m Void) |
Spawn a new thread that runs a Watcher
The thread will be linked to the registry.
Arguments
∷ ∀ m a fp r. (IOLike m, Eq fp, HasCallStack) | |
⇒ String | Label for the thread |
→ Watcher m a fp | |
→ m r | |
→ m r |
Misc
newtype Fingerprint Source #
Simple type that can be used to indicate something in a TVar
is
changed.
Constructors
Fingerprint Word64 |
Instances
data WithFingerprint a Source #
Store a value together with its fingerprint.
Constructors
WithFingerprint | |
Fields |
Instances
Functor WithFingerprint Source # | |||||
Defined in Ouroboros.Consensus.Util.STM Methods fmap ∷ (a → b) → WithFingerprint a → WithFingerprint b # (<$) ∷ a → WithFingerprint b → WithFingerprint a # | |||||
Generic (WithFingerprint a) Source # | |||||
Defined in Ouroboros.Consensus.Util.STM Associated Types
Methods from ∷ WithFingerprint a → Rep (WithFingerprint a) x # to ∷ Rep (WithFingerprint a) x → WithFingerprint a # | |||||
Show a ⇒ Show (WithFingerprint a) Source # | |||||
Defined in Ouroboros.Consensus.Util.STM Methods showsPrec ∷ Int → WithFingerprint a → ShowS # show ∷ WithFingerprint a → String # showList ∷ [WithFingerprint a] → ShowS # | |||||
Eq a ⇒ Eq (WithFingerprint a) Source # | |||||
Defined in Ouroboros.Consensus.Util.STM Methods (==) ∷ WithFingerprint a → WithFingerprint a → Bool # (/=) ∷ WithFingerprint a → WithFingerprint a → Bool # | |||||
NoThunks a ⇒ NoThunks (WithFingerprint a) Source # | |||||
Defined in Ouroboros.Consensus.Util.STM | |||||
type Rep (WithFingerprint a) Source # | |||||
Defined in Ouroboros.Consensus.Util.STM type Rep (WithFingerprint a) = D1 ('MetaData "WithFingerprint" "Ouroboros.Consensus.Util.STM" "ouroboros-consensus-0.25.0.0-inplace" 'False) (C1 ('MetaCons "WithFingerprint" 'PrefixI 'True) (S1 ('MetaSel ('Just "forgetFingerprint") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a) :*: S1 ('MetaSel ('Just "getFingerprint") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Fingerprint))) |
blockUntilChanged ∷ ∀ (m ∷ Type → Type) a b. (MonadSTM m, Eq b) ⇒ (a → b) → b → STM m a → STM m (a, b) Source #
Wait until the TVar changed
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.
Simulate various monad stacks in STM
simStateT ∷ ∀ (m ∷ Type → Type) st (n ∷ Type → Type). IOLike m ⇒ StrictTVar m st → Sim n m → Sim (StateT st n) m Source #
withTMVar
withTMVar ∷ IOLike m ⇒ StrictTMVar m a → (a → m (c, a)) → m c Source #
Apply f
with the content of tv
as state, restoring the original value when an
exception occurs
Arguments
∷ IOLike m | |
⇒ StrictTMVar m a | |
→ (a → STM m b) | Additional STM action to run in the same atomically block as the TMVar is acquired |
→ (a → b → m (c, a)) | Action |
→ m c |
Apply f
with the content of tv
as state, restoring the original value
when an exception occurs. Additionally run a STM
action when acquiring the
value.