metrics-0.4.1.1: High-performance application metric tracking

Safe HaskellNone
LanguageHaskell2010

Data.Metrics.Internal

Description

Internal helpers that provide strict atomic MutVar access.

These functions allow us to avoid the overhead of MVar as long as we can factor the impure sections of code out in such a way that the pure metric calculations can be executed without requiring access to multiple MutVars at a time.

Synopsis

Documentation

updateRef :: PrimMonad m => MV m a -> (a -> a) -> m () Source #

Perform a strict update on a MutVar. Pretty much identical to the strict variant of atomicModifyIORef.

applyWithRef :: PrimMonad m => MV m a -> (a -> b) -> m b Source #

Strictly apply a function on a MutVar while blocking other access to it.

I really think this is probably not implemented correctly in terms of being excessively strict.

updateAndApplyToRef :: PrimMonad m => MV m a -> (a -> a) -> (a -> b) -> m b Source #

A function which combines the previous two, updating a value atomically and then returning some value calculated with the update in a single step.

type MV m = MutVar (PrimState m) Source #

MutVar (PrimState m) is a little verbose.