atomic-modify-general

Version 0.1.0.0 revision 0 uploaded by dfeuer.

Package meta

Synopsis
Generalizations of atomicModifyIORef
Description

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.

Author
David Feuer
Bug reports
n/a
Category
Concurrency
Copyright
2023 David Feuer
Homepage
https://github.com/treeowl/atomic-modify-general
Maintainer
David.Feuer@gmail.com
Package URL
n/a
Stability
n/a

Components