HORIZON HASKELLDocslts/ghc-9.14.x99ffbb82026-10-19Search packagesCtrl K
Theme: |

GHC 9.14.1 · lts/ghc-9.14.x · 99ffbb8 · 2026-10-19

Modulekes-agent-crypto-1.2.0.0Haskell2010

Cardano.KESAgent.Util.RefCounting

References with a counter-based lifecycle, similar to reference-counted shared pointers. This is useful to implement shared access to scarce resources that require timely destruction (i.e., we cannot rely on GC to run finalizers).

Synopsis
typetype CRefCount = Int

Reference count. We use a signed integer so that we can catch cases where a reference is released beyond zero (which shouldn't happen, but we want to be able to detect it when it does).

datadata CRefEvent

CRef lifecycle events.

Constructors

Instances3Eq, Show, Pretty
  • Eq CRefEventDefined in kes-agent-crypto-1.2.0.0 · Cardano.KESAgent.Util.RefCounting
  • Show CRefEventDefined in kes-agent-crypto-1.2.0.0 · Cardano.KESAgent.Util.RefCounting
  • Pretty CRefEventDefined in kes-agent-crypto-1.2.0.0 · Cardano.KESAgent.Util.RefCounting

Reference underflow exception: this will be thrown when a reference count is released beyond zero (i.e., becomes negative). This is generally a bug, caused by user code releasing a reference that it hasn't acquired.

Instances3Eq, Show, Exception
valuereadCRef :: (MonadSTM m, MonadThrow m) => CRef m a -> m a

Read a CRef without acquiring it. The caller is responsible for making sure the CRef has been acquired appropriately for the duration of the call, and while using the wrapped resource. It is generally preferable to use withCRefValue instead.