atomic-primops-0.2.2: A safe approach to CAS and other atomic ops in Haskell.

Safe HaskellNone

Data.Atomics.Counter.Foreign

Description

This implementation stores an unboxed counter and uses FFI operations to modify its contents.

Synopsis

Documentation

newCounter :: IO AtomicCounterSource

Create a new counter initialized to zero.

incrCounter :: AtomicCounter -> IO IntSource

Try repeatedly until we successfully increment the counter. Returns the original value before the increment.

writeCounter :: AtomicCounter -> Int -> IO ()Source

Make a non-atomic write to the counter. No memory-barrier.