Safe Haskell | None |
---|
Documentation
:: IORef a | The |
-> a | The |
-> a | The |
-> IO (Bool, a) |
Performs a machine-level compare and swap operation on an
IORef
. Returns a tuple containing a Bool
which is True
when a
swap is performed, along with the current
value from the IORef
.
Note "compare" here means pointer equality in the sense of
reallyUnsafePtrEquality#
.
atomicModifyIORefCAS :: IORef a -> (a -> (a, b)) -> IO bSource
A drop-in replacement for atomicModifyIORefCAS
that
optimistically attempts to compute the new value and CAS it into
place without introducing new thunks or locking anything. Note
that this is more STRICT than its standard counterpart and will only
place evaluated (WHNF) values in the IORef.
atomicModifyIORefCAS_ :: IORef t -> (t -> t) -> IO ()Source
A simpler version that modifies the state but does not return anything.