Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data IORefU a
- newIORefU :: Prim a => a -> IO (IORefU a)
- readIORefU :: Prim a => IORefU a -> IO a
- writeIORefU :: Prim a => IORefU a -> a -> IO ()
- modifyIORefU :: Prim a => IORefU a -> (a -> a) -> IO ()
- type Counter = IORefU Int
- newCounter :: Int -> IO Counter
- atomicAddCounter :: Counter -> Int -> IO Int
- atomicSubCounter :: Counter -> Int -> IO Int
- atomicAndCounter :: Counter -> Int -> IO Int
- atomicNandCounter :: Counter -> Int -> IO Int
- atomicOrCounter :: Counter -> Int -> IO Int
- atomicXorCounter :: Counter -> Int -> IO Int
- atomicAddCounter_ :: Counter -> Int -> IO Int
- atomicSubCounter_ :: Counter -> Int -> IO Int
- atomicAndCounter_ :: Counter -> Int -> IO Int
- atomicNandCounter_ :: Counter -> Int -> IO Int
- atomicOrCounter_ :: Counter -> Int -> IO Int
- atomicXorCounter_ :: Counter -> Int -> IO Int
Unboxed IO references
modifyIORefU :: Prim a => IORefU a -> (a -> a) -> IO () Source #
Mutate the contents of an IORef
.
Unboxed reference is always strict on the value it hold.
Atomic operations for IORefU Int
atomicAddCounter :: Counter -> Int -> IO Int Source #
Atomically add a Counter
, return the value AFTER added.
It's implemented using fetch-and-add primitive, which is much faster than a CAS loop(atomicModifyIORef
).
atomicSubCounter :: Counter -> Int -> IO Int Source #
Atomically sub a Counter
, return the value AFTER subbed.
atomicAndCounter :: Counter -> Int -> IO Int Source #
Atomically and a Counter
, return the value AFTER anded.
atomicNandCounter :: Counter -> Int -> IO Int Source #
Atomically nand a Counter
, return the value AFTER nanded.
atomicOrCounter :: Counter -> Int -> IO Int Source #
Atomically or a Counter
, return the value AFTER ored.
atomicXorCounter :: Counter -> Int -> IO Int Source #
Atomically xor a Counter
, return the value AFTER xored.
atomicAddCounter_ :: Counter -> Int -> IO Int Source #
Atomically add a Counter
, return the value BEFORE added.
Since: 0.4.0.0
atomicSubCounter_ :: Counter -> Int -> IO Int Source #
Atomically sub a Counter
, return the value BEFORE subbed.
Since: 0.4.0.0
atomicAndCounter_ :: Counter -> Int -> IO Int Source #
Atomically and a Counter
, return the value BEFORE anded.
You can leverage idempotence of anding zero to make a concurrent resource lock.
Since: 0.4.0.0
atomicNandCounter_ :: Counter -> Int -> IO Int Source #
Atomically nand a Counter
, return the value BEFORE nanded.
Since: 0.4.0.0