Performs an atomic compare-and-exchange operation on the specified values. The function compares the specified 64-bit values and exchanges with the specified 128-bit value based on the outcome of the comparison.
LONG64 __cdecl InterlockedCompare64Exchange128( _Inout_ LONG64 volatile *Destination, _In_ LONG64 ExchangeHigh, _In_ LONG64 ExchangeLow, _In_ LONG64 Comparand );
- Destination [in, out]
A pointer to the destination value.
- ExchangeHigh [in]
The high-order part of the exchange value.
- ExchangeLow [in]
The low-order part of the exchange value.
- Comparand [in]
The value to compare to Destination.
The function returns the initial value of the Destination parameter.
The function compares the Destination value with the Comparand value. If the Destination value is equal to the Comparand value, the Exchange value is stored in the address specified by Destination. Otherwise, no operation is performed. The variable pointed to by the Destination parameter must be aligned on a 128-bit boundary. See _aligned_malloc.
To determine whether the processor supports this operation, call the IsProcessorFeaturePresent function with PF_COMPARE64_EXCHANGE128.
The interlocked functions provide a simple mechanism for synchronizing access to a variable that is shared by multiple threads. This function is atomic with respect to calls to other interlocked functions.
This function is implemented using a compiler intrinsic where possible. For more information, see the WinBase.h header file and _InterlockedCompare64Exchange128.
This function generates a full memory barrier (or fence) to ensure that memory operations are completed in order.
- Interlocked Variable Access
- Synchronization Functions