ecluse:ecluse-runtime
Safe HaskellNone
LanguageGHC2021

Ecluse.Runtime.Telemetry.Batched.Cells

Description

One mutable cell per capability. A writer updates its own capability's cell by compare-and-swap, evaluating the new value first, so it races another writer only when one is preempted between its read and its swap. The loop is atomic-primops' own, compiled in the library, because coverage instrumentation in the caller breaks the swap's pointer test. After 30 failed swaps it falls back to a lazy update, which the next writer or a drain evaluates.

Synopsis

Documentation

data Cells a Source #

One cell per capability the runtime had when the cells were made, each starting from the blank value.

newCells :: a -> IO (Cells a) Source #

Make one cell per capability.

modifyOwnCell :: Cells a -> (a -> a) -> IO () Source #

Apply a change to the calling thread's cell. A change that builds a strict value is evaluated whole.

drainCells :: Cells a -> IO [a] Source #

Take every cell's value, leaving the blank value in its place.