Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data UnliftedMutVar# s (a :: UnliftedType)
- newUnliftedMutVar# :: a -> State# s -> (# State# s, UnliftedMutVar# s a #)
- readUnliftedMutVar# :: UnliftedMutVar# s a -> State# s -> (# State# s, a #)
- writeUnliftedMutVar# :: UnliftedMutVar# s a -> a -> State# s -> State# s
- sameUnliftedMutVar# :: UnliftedMutVar# s a -> UnliftedMutVar# s a -> Int#
- casUnliftedMutVar# :: UnliftedMutVar# s a -> a -> a -> State# s -> (# State# s, Int#, a #)
- atomicSwapUnliftedMutVar# :: UnliftedMutVar# s a -> a -> State# s -> (# State# s, a #)
Documentation
data UnliftedMutVar# s (a :: UnliftedType) Source #
An UnliftedMutVar#
behaves like a single-element mutable array.
newUnliftedMutVar# :: a -> State# s -> (# State# s, UnliftedMutVar# s a #) Source #
readUnliftedMutVar# :: UnliftedMutVar# s a -> State# s -> (# State# s, a #) Source #
writeUnliftedMutVar# :: UnliftedMutVar# s a -> a -> State# s -> State# s Source #
sameUnliftedMutVar# :: UnliftedMutVar# s a -> UnliftedMutVar# s a -> Int# Source #
Check whether two UnliftedMutVar#
es refer to the same mutable
variable. This is a check on object identity, and not on contents.
:: UnliftedMutVar# s a | The |
-> a | The expected value |
-> a | The new value to install if the 'UnliftedMutVar# contains the expected value |
-> State# s | |
-> (# State# s, Int#, a #) |
Performs a machine-level compare and swap (CAS) operation on an
UnliftedMutVar#
. Returns a tuple containing an Int#
which is '1#' when a
swap is performed, along with the most "current" value from the
UnliftedMutVar#
. This return value can be used as the expected value if a
CAS loop is required, though it may be better to get a fresh read. Note
that this behavior differs from the more common CAS behavior, which is to
return the old value before the CAS occured.
atomicSwapUnliftedMutVar# :: UnliftedMutVar# s a -> a -> State# s -> (# State# s, a #) Source #
Atomically replace the value in an UnliftedMutVar#
with the given one,
returning the old value.
Implementation note: this really should be a GHC primop, because it is supported very efficiently in hardware, but unfortunately it's not (yet), so we implement it as a CAS loop.