IORefCAS-0.2: 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 where

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)

readCASable :: casref a -> IO a

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

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

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.

unsafeName :: a -> Int

ptrEq :: a -> a -> Bool