Moduleouroboros-consensus-4.2.1.0
Ouroboros.Consensus.Util.NormalForm.StrictMVar
- 2 types
- 1 class
- 26 values
- Packageouroboros-consensus-4.2.1.0
- Exports29
- LicenceApache-2.0
- SourceChecked.hs
Check invariant (if enabled) before continuing
checkInvariant mErr x is equal to x if mErr == Nothing, and throws
an error err if mErr == Just err.
This is exported so that other code that wants to conditionally check invariants can reuse the same logic, rather than having to introduce new per-package flags.
Create a StrictMVar from a LazyMVar
It is not guaranteed that the LazyMVar contains a value that is in WHNF, so there is no guarantee that the resulting StrictMVar contains a value that is in WHNF. This should be used with caution.
The resulting StrictMVar has a trivial invariant.
modifyMVarMasked_ is defined in terms of modifyMVarMasked.
modifyMVar_ is defined in terms of modifyMVar.
Get the underlying MVar
Since we obviously can not guarantee that updates to this LazyMVar will be strict, this should be used with caution.
Similarly, we can not guarantee that updates to this LazyMVar do not break the original invariant that the StrictMVar held.
Create an unchecked reference to the given checked StrictMVar.
Note that the invariant is only guaranteed when modifying the checked MVar. Any modification to the unchecked reference might break the invariants.
Instances3MonadMVar
MonadMVar IODefined in io-classes-1.8.0.1 · Control.Concurrent.Class.MonadMVar(MonadMVar m, MonadMask m, MonadEvaluate m) => MonadMVar (WithEarlyExit m)Defined in ouroboros-consensus-4.2.1.0 · Ouroboros.Consensus.Util.EarlyExit(MonadMask m, MonadMVar m) => MonadMVar (ReaderT r m)Defined in io-classes-1.8.0.1 · Control.Concurrent.Class.MonadMVar
A strict MVar with invariant checking.
There is a weaker invariant for a StrictMVar than for a StrictTVar:
although all functions that modify the StrictMVar check the invariant, we
do not guarantee that the value inside the StrictMVar always satisfies
the invariant. Instead, we do guarantee that if the StrictMVar is updated
with a value that does not satisfy the invariant, an exception is thrown. The
reason for this weaker guarantee is that leaving an MVar empty can lead to
very hard to debug "blocked indefinitely" problems.
Instances1NoThunks
NoThunks (StrictMVar IO a) => NoThunks (StrictMVar IO a)Defined in ouroboros-consensus-4.2.1.0 · Ouroboros.Consensus.Util.NormalForm.StrictMVar · orphan
Orphan instances
1 instanceNoThunks (StrictMVar IO a) => NoThunks (StrictMVar IO a)