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

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 2b27632 · 2026-10-31

Moduleatomic-counter-0.1.2.4Haskell2010

Control.Concurrent.Counter.Lifted.ST

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).

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

Memory location that supports select few atomic operations.

Isomorphic to STRef s Int.

Instances1Eq
  • Eq (Counter s)Defined in atomic-counter-0.1.2.4 · Control.Concurrent.Counter.Lifted.ST

    Pointer equality

Create

Read/write

valuecas
  1. :: Counter s
  2. -> Int

    Expected old value

  3. -> Int

    New value

  4. -> ST 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

valueand :: Counter s -> Int -> ST s Int

Atomically combine old value with a new one via bitwise and. Returns old counter value.

valueor :: Counter s -> Int -> ST s Int

Atomically combine old value with a new one via bitwise or. Returns old counter value.

valuexor :: Counter s -> Int -> ST s Int

Atomically combine old value with a new one via bitwise xor. Returns old counter value.

valuenand :: Counter s -> Int -> ST s Int

Atomically combine old value with a new one via bitwise nand. Returns old counter value.