@hackage / atomic-modify-general

Generalizations of atomicModifyIORef

Latest0.1.0.0

About

Metadata

  • Last updated , by dfeuer
  • License BSD-2-Clause
  • Categories Concurrency
  • Maintained by: David.Feuer@gmail.com

  • Lottery factor: 0

Links

Installation

Tested Compilers

  1. 9.6.1
  2. 9.4.4
  3. 9.2.7
  4. 9.0.2
  5. 8.10.7
  6. 8.8.4
  7. 8.6.5
  8. 8.4.4

Readme

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.