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