interlockedCompareExchange64 函式 (winnt.h)

在指定的值上執行不可部分完成的比較和交換作業。 函式會根據比較的結果,比較兩個指定的64位值,並與另一個64位值交換。

語法

LONG64 InterlockedCompareExchange64(
  [in, out] LONG64 volatile *Destination,
  [in]      LONG64          ExChange,
  [in]      LONG64          Comperand
);

參數

[in, out] Destination

目的地值的指標。

[in] ExChange

交換值。

[in] Comperand

要與 Destination 比較的值。

傳回值

函式會傳回 Destination 參數的初始值。

備註

函式會比較 Destination 值與 Compareand 值。 如果 Destination 值等於 Comparand 值, Exchange 值會儲存在 Destination 所指定的位址中。 否則,不會執行任何作業。

此函式的變數必須在64位界限上對齊;否則,此函式會在多處理器 x86 系統和任何非 x86 系統上發生無法預期的行為。 請參閱 _aligned_malloc

連結函式提供簡單的機制,可同步存取多個線程所共享的變數。 此函式對其他連結函式的呼叫是不可部分完成的。

此函式會盡可能使用編譯程式內部函數來實作。 如需詳細資訊,請參閱 WinBase.h 頭文件與 _InterlockedCompareExchange64

此函式會產生完整的記憶體屏障 (或柵欄) ,以確保記憶體作業會依序完成。

Itanium 型系統: 對於效能關鍵性應用程式,請改用 InterlockedCompareExchangeAcquire64InterlockedCompareExchangeRelease64

注意Windows RT 型系統支援此函式。
 

規格需求

需求
最低支援的用戶端 Windows Vista [傳統型應用程式 |UWP 應用程式]
最低支援的伺服器 Windows Server 2003 [傳統型應用程式 |UWP 應用程式]
目標平台 Windows
標頭 winnt.h (包含 Windows.h)
程式庫 Kernel32.lib
DLL Kernel32.dll

另請參閱

Interlocked Variable Access

InterlockedCompare64Exchange128

InterlockedCompareExchange

InterlockedCompareExchange128

InterlockedCompareExchange16

InterlockedCompareExchange16Acquire

InterlockedCompareExchange16NoFence

InterlockedCompareExchange16Release

InterlockedCompareExchangeAcquire

InterlockedCompareExchangeAcquire64

InterlockedCompareExchangeNoFence

InterlockedCompareExchangeNoFence64

InterlockedCompareExchangePointer

InterlockedCompareExchangePointerAcquire

InterlockedCompareExchangePointerNoFence

InterlockedCompareExchangePointerRelease

InterlockedCompareExchangeRelease

InterlockedCompareExchangeRelease64

同步處理函式