Memory location that supports select few atomic operations.
Isomorphic to STRef s Int.
:: a typeCtrl KGHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27
Moduleatomic-counter-0.1.2.4Haskell2010
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).
Memory location that supports select few atomic operations.
Isomorphic to STRef s Int.
Create new counter with initial value.
Atomically read the counter's value.
Atomically assign new value to the counter.
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
Atomically add an amount to the counter and return its old value.
Atomically subtract an amount from the counter and return its old value.
Atomically combine old value with a new one via bitwise and. Returns old counter value.
Atomically combine old value with a new one via bitwise or. Returns old counter value.
Atomically combine old value with a new one via bitwise xor. Returns old counter value.
Atomically combine old value with a new one via bitwise nand. Returns old counter value.