Memory location that supports select few atomic operations.
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.
- 1 type
- 11 values
- Packageatomic-counter-0.1.2.4
- Exports12
- LanguageHaskell2010
- LicenceApache-2.0
- SourceUnlifted.hs
Create
1 declarationCreate new counter with initial value.
Read/write
3 declarationsAtomically 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
Arithmetic operations
2 declarationsAtomically add an amount to the counter and return its old value.
Atomically subtract an amount from the counter and return its old value.
Bitwise operations
4 declarationsAtomically 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.
Compare
1 declarationCompare the underlying pointers of two counters.