天天看點

InterlockedCompareExchange例程

InterlockedCompareExchange 例程執行一個原子操作,用參數Comparand的值與參數Destination指針指向的值比較。

Syntax:

LONG InterlockedCompareExchange(
 _Inout_ LONG volatile * Destination,
 _In_ LONG Exchange,
 _In_ LONG Comparand
 );
           

Parameters:

Destination [in, out]

指向輸入值的指針,和Comparand的值比較。

Exchange [in]

如果Destination指針指向的值和Comparand的值一樣,就把Destination指針指向的值換成Exchange的值。

Comparand [in]指定與Destination 指針指向值比較的值。

Return value

傳回*Destination的原始值。

Remarks

當Comparand 和*Destination相等時,*Destination的值設為Exchange 一樣。否則,*Destination值不變。

Requirements

Header

Wdm.h (include Wdm.h, Ntddk.h, or Ntifs.h)

Library

OneCoreUAP.lib on Windows 10

IRQL

Any level

See also

ExInterlockedCompareExchange64

InterlockedCompareExchangePointer

InterlockedDecrement

InterlockedExchange

InterlockedExchangePointer

InterlockedIncrement

繼續閱讀