共用方式為


InterlockedCompare64ExchangeAcquire128 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. The operation is performed with acquire memory ordering semantics.

Syntax

LONG64 __cdecl InterlockedCompare64ExchangeAcquire128(
  _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 performs an atomic comparison of 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_acq.

Requirements

Header

WinBase.h (include Windows.h)

See also

Interlocked Variable Access

InterlockedCompare64Exchange128

InterlockedCompare64ExchangeRelease128

InterlockedCompareExchangeAcquire64

Synchronization Functions