win32 API InterlockedCompareExchange

来源:互联网 发布:淘宝话费定期充值 编辑:程序博客网 时间:2024/05/10 22:27

函数原型:

LONG __cdecl InterlockedCompareExchange(
  __in_out      LONG volatile* Destination,
  __in          LONG Exchange,
  __in          LONG Comparand
);

MSDN上的解释:

Performs an atomic compare-and-exchange operation on the specified values. The function compares two specified 32-bit values and exchanges with another 32-bit value based on the outcome of the comparison.

 

我的理解:

第一个参数和第三个参数比较,如果相等,则将第一个参数的值设为第个参数的值.

 

Return Value

The function returns the initial value of the Destination parameter.

 

返回的是第一个参数的初始值

原创粉丝点击