ref-0.1.1.2: Generic Mutable Ref Abstraction Layer

Safe HaskellNone

Data.Ref.CAS

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.

Note "compare" here means pointer equality in the sense of reallyUnsafePtrEquality#.

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.

Note "compare" here means pointer equality in the sense of reallyUnsafePtrEquality#.