Proposal: Add atomic IORef operations to Data.IORef

chessai chessai1996 at gmail.com
Fri Jan 15 20:10:40 UTC 2021


+1 with sufficient documentation

On Fri, Jan 15, 2021, 14:06 David Feuer <david.feuer at gmail.com> wrote:

> GHC.IORef currently exports
>
> atomicModifyIORef2 :: IORef a -> (a -> (a,b)) -> IO (a, (a, b))
> atomicSwapIORef :: IORef a -> a -> IO a
>
> atomicModifyIORef2 is a lot like atomicModifyIORef, but it returns
> both the old value in the IORef and the full result of applying the
> user-supplied function to that. This is a pretty thin wrapper around
> the newish atomicModifyMutVar2# primop, which has replaced the less
> powerful atomicModifyMutVar#.
>
> atomicSwapIORef atomically installs a user-supplied value in an IORef
> and returns the old value. It is currently implemented using
> atomicModifyIORef2, but it can and should be reimplemented using its
> own, more efficient primop.
>
> I propose to add both of these functions to Data.IORef.
>
> David
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20210115/2fa7cc1d/attachment.html>


More information about the Libraries mailing list