Defines a set of atomic integer operations that can be used as lightweight synchronization or as building blocks for heavier synchronization primitives. Their use is very subtle and requires detailed understanding of the behavior of supported architectures, so their direct use is not recommended except when rigorously deemed absolutely necessary for performance reasons.
64-bit atomic operations (only available on 64-bit processors).
typedef int64_t SbAtomic64
Pointer-sized atomic operations. Forwards to either 32-bit or 64-bit functions as appropriate.
typedef SbAtomic32 SbAtomicPtr
These following lower-level operations are typically useful only to people implementing higher-level synchronization operations like spinlocks, mutexes, and condition-variables. They combine CompareAndSwap(), a load, or a store with appropriate memory-ordering instructions. "Acquire" operations ensure that no later memory access can be reordered ahead of the operation. "Release" operations ensure that no previous memory access can be reordered after the operation. "Barrier" operations have both "Acquire" and "Release" semantics. A SbAtomicMemoryBarrier() has "Barrier" semantics, but does no memory access.
static SbAtomic32 SbAtomicAcquire_CompareAndSwap(volatile SbAtomic32 *ptr, SbAtomic32 old_value, SbAtomic32 new_value)
Same as SbAtomicNoBarrier_Increment, but with a memory barrier.
static SbAtomic32 SbAtomicBarrier_Increment(volatile SbAtomic32 *ptr, SbAtomic32 increment)
Atomically execute: result = *ptr; if (*ptr == old_value) *ptr = new_value; return result;
I.e., replace "ptr" with "new_value" if "*ptr" used to be "old_value". Always return the old value of "ptr"
This routine implies no memory barriers.
static SbAtomic32 SbAtomicNoBarrier_CompareAndSwap(volatile SbAtomic32 *ptr, SbAtomic32 old_value, SbAtomic32 new_value)
Atomically store new_value into *ptr, returning the previous value held in *ptr. This routine implies no memory barriers.
static SbAtomic32 SbAtomicNoBarrier_Exchange(volatile SbAtomic32 *ptr, SbAtomic32 new_value)
Atomically increment *ptr by "increment". Returns the new value of *ptr with the increment applied. This routine implies no memory barriers.
static SbAtomic32 SbAtomicNoBarrier_Increment(volatile SbAtomic32 *ptr, SbAtomic32 increment)
Overloaded functions for Atomic8.
static SbAtomic8 SbAtomicRelease_CompareAndSwap8(volatile SbAtomic8 *ptr, SbAtomic8 old_value, SbAtomic8 new_value)