-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Generalizations of atomicModifyIORef -- -- base provides -- --
--   atomicModifyIORef :: IORef a -> (a -> (a, b)) -> IO b
--   atomicModifyIORef2 :: IORef a -> (a -> (a, b)) -> IO (a, (a, b))
--   
-- -- to modify the value in an IORef and return a result (and, in -- the case of atomicModifyIORef2, also return the old value). -- -- In Data.IORef.AtomicModify, we generalize this from pairs to -- arbitrary types for which the user can provide a function to extract -- the new value to store in the IORef. -- -- In Data.IORef.AtomicModify.Generic, we offer a faster but more -- restricted version taking advantage of the fact that the primop used -- to implement atomicModifyIORef2 actually works for -- somewhat more general record types than -- atomicModifyIORef2 accepts. @package atomic-modify-general @version 0.1.0.0 -- | Atomic modification for more general records, using GHC generics to -- check their suitablility. When applicable, this is faster than the -- general utilities in Data.IORef.AtomicModify. module Data.IORef.AtomicModify.Generic atomicModifyIORef2Native :: (EnsureGenericData t, FirstField t (Rep t) ~ a) => IORef a -> (a -> t) -> IO (a, t) -- | Atomic IORef and array modification operations for more general -- result types. module Data.IORef.AtomicModify -- | A version of atomicModifyIORef2 that takes an arbitrary pair of -- functions. This function will allocate more than -- atomicModifyIORef2, and will tend to take longer to succeed -- when there is a lot of contention for the IORef. -- --
--   atomicModifyIORef2 ref f = do
--     (old, _new, r) <- atomicModifyIORef2General ref fst f
--     pure (old, r)
--   
-- -- If the first function (the "extraction function") is a record field -- selector (e.g., snd), we do our best to make sure the thunk -- placed in the IORef is a selector thunk, so the garbage -- collector can drop the rest of the record once the record is forced. -- In other cases, callers should generally force the returned -- new value in order to avoid a potential space leak. -- -- Conceptually: -- --
--   atomicModifyIORef3General ref extract f = do
--     -- Begin atomic block
--     old <- readIORef ref
--     let r = f old
--         new = extract r
--     writeIORef ref new
--     -- End atomic block
--     r seq pure (old, new, r)
--   
-- -- where other threads cannot interfere with the operations in the -- "atomic block". In particular, no other thread can write to the -- IORef between the readIORef and the writeIORef -- operations. atomicModifyIORef3General :: IORef a -> (t -> a) -> (a -> t) -> IO (a, a, t) -- | A version of atomicModifyIORef3General for Arrays. See -- the documentation there. Indexing is performed safely. atomicModifyArray3General :: MutableArray RealWorld a -> Int -> (t -> a) -> (a -> t) -> IO (a, a, t) -- | A version of atomicModifyIORef3General for SmallArrays. -- See the documentation there. Indexing is performed safely. atomicModifySmallArray3General :: SmallMutableArray RealWorld a -> Int -> (t -> a) -> (a -> t) -> IO (a, a, t)