Compartir a través de


InterlockedCompare64Exchange128 function

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.

Syntax

LONG64 __cdecl InterlockedCompare64Exchange128(
  _Inout_ LONG64 volatile *Destination,
  _In_    LONG64          ExchangeHigh,
  _In_    LONG64          ExchangeLow,
  _In_    LONG64          Comparand
);

Parameters

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

Return value

The function returns the initial value of the Destination parameter.

Remarks

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.

Itanium-based systems: For performance-critical applications, use InterlockedCompare64ExchangeAcquire128 or InterlockedCompare64ExchangeRelease128 instead.

Requirements

Header

WinBase.h (include Windows.h)

See also

Interlocked Variable Access

InterlockedCompare64ExchangeAcquire128

InterlockedCompare64ExchangeRelease128

InterlockedCompareExchange64

Synchronization Functions