-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Atomic compare and swap for IORefs and STRefs.
--
-- After GHC 7.2 a new `casMutVar#` primop became available, but was not
-- yet exposed in Data.IORef. This package fills that gap until such a
-- time as Data.IORef obsoletes it.
--
-- Further, in addition to exposing native Haskell CAS operations, this
-- package contains "mockups" that imititate the same functionality using
-- either atomicModifyIORef and unsafe pointer equality (in
-- Data.CAS.Fake) or using foreign functions
-- (Data.CAS.Foreign). These alternatives are useful for
-- debugging.
--
-- Note that the foreign option does not operate on IORefs and so is
-- directly interchangeable with Data.CAS and Data.CAS.Fake
-- only if the interface in Data.CAS.Class is used.
@package IORefCAS
@version 0.2
-- | A type class capturing mutable storage cells that support CAS
-- operations in the IO monad.
module Data.CAS.Internal.Class
-- | It would be nice to use an associated type family with this class (for
-- casref), but that would preclude overlapping instances.
class CASable casref a
newCASable :: CASable casref a => a -> IO (casref a)
readCASable :: CASable casref a => casref a -> IO a
writeCASable :: CASable casref a => casref a -> a -> IO ()
cas :: CASable casref a => casref a -> a -> a -> IO (Bool, a)
unsafeName :: a -> Int
ptrEq :: a -> a -> Bool
-- | This is a version of CAS that works outside of Haskell by using the
-- FFI (and the GCC intrinsics-based Data.Bits.Atomic.)
module Data.CAS.Internal.Foreign
data CASRef a
instance [overlap ok] CASable CASRef Word32
-- | This is an attempt to imitate a CAS using normal Haskell/GHC
-- operations. Useful for debugging.
module Data.CAS.Internal.Fake
-- | The type of references supporting CAS.
data CASRef a
casIORef :: IORef a -> a -> a -> IO (Bool, a)
ptrEq :: a -> a -> Bool
atomicModifyIORefCAS :: IORef a -> (a -> (a, b)) -> IO b
atomicModifyIORefCAS_ :: IORef a -> (a -> a) -> IO ()
instance CASable CASRef a
-- | Atomic compare and swap for IORefs and STRefs.
module Data.CAS
casIORef :: IORef a -> a -> a -> IO (Bool, a)
ptrEq :: a -> a -> Bool
atomicModifyIORefCAS :: IORef a -> (a -> (a, b)) -> IO b
atomicModifyIORefCAS_ :: IORef a -> (a -> a) -> IO ()
-- | The type of references supporting CAS.
data CASRef a