| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
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
- data Cells a
- newCells :: a -> IO (Cells a)
- modifyOwnCell :: Cells a -> (a -> a) -> IO ()
- drainCells :: Cells a -> IO [a]
Documentation
One cell per capability the runtime had when the cells were made, each starting from the blank value.
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.