A safe approach to CAS and other atomic ops in Haskell.

Version on this page:
LTS Haskell 22.29:0.8.8
Stackage Nightly 2024-07-19:0.8.8
Latest on Hackage:0.8.8

See all snapshots atomic-primops appears in

BSD-3-Clause licensed by Ryan Newton
Maintained by [email protected]
This version can be pinned in stack with:atomic-primops-,5396

Module documentation for

Used by 1 package in lts-3.22(full list with versions):

After GHC 7.4 a new casMutVar# primop became available, but it's difficult to use safely, because pointer equality is a highly unstable property in Haskell. This library provides a safer method based on the concept of Tickets.

Also, this library uses the "foreign primop" capability of GHC to add access to other variants that may be of interest, specifically, compare and swap inside an array.

Note that as of GHC 7.8, the relevant primops have been included in GHC itself. This library is engineered to work pre- and post-GHC-7.8, while exposing the same interface.

Changes in 0.3:

  • Major internal change. Duplicate the barrier code from the GHC RTS and thus enable support for executables that are NOT built with '-threaded'.

Changes in 0.4:

  • Further internal changes, duplicate cas routine well as barriers.

  • Add fetchAddByteArrayInt

  • Add an Unboxed counter variant that uses movable ByteArrays on the GHC heap.

Changes in 0.5:

  • Remove dependency on bits-atomic unless a flag is turned on.

Changes in

  • IMPORTANT BUGFIXES - don't use earlier versions. They have been marked deprecated.

Changes in 0.6.1

  • This is a good version to use for GHC 7.8.3. It includes portability and bug fixes and adds atomicModifyIORefCAS.

Changes in 0.7:

  • This release adds support for GHC 7.10 and its expanded library of (now inline) primops.

Changes in 0.8:

  • Implements additional fetch primops available in GHC 7.10