atomic-modify-general: Generalizations of atomicModifyIORef

[ bsd2, concurrency, library ] [ Propose Tags ] [ Report a vulnerability ]

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.

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0
Change log CHANGELOG.md
Dependencies base (>=4.11 && <4.19), primitive [details]
Tested with ghc ==8.4.4, ghc ==8.6.5, ghc ==8.8.4, ghc ==8.10.7, ghc ==9.0.2, ghc ==9.2.7, ghc ==9.4.4, ghc ==9.6.1
License BSD-2-Clause
Copyright 2023 David Feuer
Author David Feuer
Maintainer David.Feuer@gmail.com
Category Concurrency
Home page https://github.com/treeowl/atomic-modify-general
Source repo head: git clone http://github.com/treeowl/atomic-modify-general.git
Uploaded by dfeuer at 2023-03-10T01:50:25Z
Distributions NixOS:0.1.0.0
Downloads 87 total (3 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2023-03-10 [all 1 reports]