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

Safe HaskellNone

Data.CAS.Internal.Class

Description

A type class capturing mutable storage cells that support CAS operations in the IO monad.

Synopsis

Documentation

class CASable casref a whereSource

It would be nice to use an associated type family with this class (for casref), but that would preclude overlapping instances.

Methods

newCASable :: a -> IO (casref a)Source

readCASable :: casref a -> IO aSource

writeCASable :: casref a -> a -> IO ()Source

cas :: casref a -> a -> a -> IO (Bool, a)Source

Instances

CASable CASRef a 
CASable CASRef a 
CASable CASRef Word32

EXAMPLE SPECIALIZATION: a more efficient implementation for simple scalars.

Boilerplate TODO: We Should have one of these for all word-sized Scalar types.

ptrEq :: a -> a -> BoolSource