HORIZON HASKELLDocslts/ghc-10.0.x77a86622026-10-31Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 77a8662 · 2026-10-31

Moduleatomic-counter-0.1.2.4Haskell2010

Control.Concurrent.Counter.Unlifted

Counters that support some atomic operations. Safe to use from multiple threads and likely faster than using IORef or TVar for the same operation (terms and conditions apply).

This module defines unlifted newtype wrapper and corresponding operations, they're not suitable for use with e.g. monads or being stored in other data structures that expect lifted types. For general use start with Control.Concurrent.Counter.Counter module.

Contents
  1. Create
  2. Read/write
  3. Arithmetic operations
  4. Bitwise operations
  5. Compare
Synopsis
newtypenewtype Counter s

Memory location that supports select few atomic operations.

Create

Read/write

valuecas :: Counter s -> Int# -> Int# -> State# s -> (# State# s, Int# #)

Atomic compare and swap, i.e. write the new value if the current value matches the provided old value. Returns the value of the element before the operation

Arithmetic operations

Bitwise operations

Compare