IORefCAS-0.0.1.2: Atomic compare and swap for IORefs and STRefs.

Data.CAS

Contents

Description

Atomic compare and swap for IORefs and STRefs.

Synopsis

Documentation

casSTRefSource

Arguments

:: STRef s a

The STRef containing a value current

-> a

The old value to compare

-> a

The new value to replace current if old == current

-> ST s (Bool, a) 

Performs a machine-level compare and swap operation on an STRef. Returns a tuple containing a Bool which is True when a swap is performed, along with the current value from the STRef.

casIORefSource

Arguments

:: IORef a

The IORef containing a value current

-> a

The old value to compare

-> a

The new value to replace current if old == current

-> 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.

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 STRICTer 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.

Generic interface: for interoperation with Fake and Foreign alternative libraries.

data CASRef a Source

Instances