Safe Haskell | None |
---|
This module provides only the raw primops (and necessary types) for atomic operations.
- casIntArray# :: MutableByteArray# s -> Int# -> Int# -> Int# -> State# s -> (#State# s, Int##)
- fetchAddIntArray# :: MutableByteArray# s -> Int# -> Int# -> State# s -> (#State# s, Int##)
- readForCAS# :: MutVar# RealWorld a -> State# RealWorld -> (#State# RealWorld, Ticket a#)
- casMutVarTicketed# :: MutVar# RealWorld a -> Ticket a -> Ticket a -> State# RealWorld -> (#State# RealWorld, Int#, Ticket a#)
- casArrayTicketed# :: MutableArray# RealWorld a -> Int# -> Ticket a -> Ticket a -> State# RealWorld -> (#State# RealWorld, Int#, Ticket a#)
- type Ticket a = Any a
Documentation
casIntArray# :: MutableByteArray# s -> Int# -> Int# -> Int# -> State# s -> (#State# s, Int##)Source
fetchAddIntArray# :: MutableByteArray# s -> Int# -> Int# -> State# s -> (#State# s, Int##)Source
casMutVarTicketed# :: MutVar# RealWorld a -> Ticket a -> Ticket a -> State# RealWorld -> (#State# RealWorld, Int#, Ticket a#)Source
casArrayTicketed# :: MutableArray# RealWorld a -> Int# -> Ticket a -> Ticket a -> State# RealWorld -> (#State# RealWorld, Int#, Ticket a#)Source
Unsafe, machine-level atomic compare and swap on an element within an Array.
When performing compare-and-swaps, the ticket encapsulates proof that a thread observed a specific previous value of a mutable variable. It is provided in lieu of the old value to compare-and-swap.
Design note: Ticket
s exist to hide objects from the GHC compiler, which
can normally perform many optimizations that change pointer equality. A Ticket,
on the other hand, is a first-class object that can be handled by the user,
but will not have its pointer identity changed by compiler optimizations
(but will of course, change addresses during garbage collection).