Copyright | (c) Sergey Vinokurov 2022 |
---|---|
License | Apache-2.0 (see LICENSE) |
Maintainer | serg.foo@gmail.com |
Safe Haskell | None |
Language | Haskell2010 |
Control.Concurrent.Counter.Lifted.IO
Synopsis
- data Counter
- new :: Int -> IO Counter
- get :: Counter -> IO Int
- set :: Counter -> Int -> IO ()
- cas :: Counter -> Int -> Int -> IO Int
- add :: Counter -> Int -> IO Int
- sub :: Counter -> Int -> IO Int
- and :: Counter -> Int -> IO Int
- or :: Counter -> Int -> IO Int
- xor :: Counter -> Int -> IO Int
- nand :: Counter -> Int -> IO Int
Documentation
Memory location that supports select few atomic operations.
Isomorphic to IORef Int
.
Create
Read/write
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
sub :: Counter -> Int -> IO Int #
Atomically subtract an amount from the counter and return its old value.
Bitwise operations
and :: Counter -> Int -> IO Int #
Atomically combine old value with a new one via bitwise and. Returns old counter value.
or :: Counter -> Int -> IO Int #
Atomically combine old value with a new one via bitwise or. Returns old counter value.