IORef

module Data.IORef
base Data.IORef
Mutable references in the IO monad.
data IORef a
base Data.IORef
A mutable variable in the IO monad
package IORefCAS
package
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. Version 0.2.0.1
atomicModifyIORef :: IORef a -> (a -> (a, b)) -> IO b
base Data.IORef
Atomically modifies the contents of an IORef. This function is useful for using IORef in a safe way in a multithreaded program. If you only have one IORef, then using atomicModifyIORef to access and modify it will prevent race conditions. Extending the atomicity to multiple IORefs is problematic, so it is recommended that if you need to do anything more complicated then using Control.Concurrent.MVar.MVar instead is a good idea.
mkWeakIORef :: IORef a -> IO () -> IO (Weak (IORef a))
base Data.IORef
Make a Weak pointer to an IORef
modifyIORef :: IORef a -> (a -> a) -> IO ()
base Data.IORef
Mutate the contents of an IORef
newIORef :: a -> IO (IORef a)
base Data.IORef
Build a new IORef
readIORef :: IORef a -> IO a
base Data.IORef
Read the value of an IORef
writeIORef :: IORef a -> a -> IO ()
base Data.IORef
Write a new value into an IORef