interlockedAnd 函数 (winnt.h)

对指定的 LONG 值执行原子 AND 操作。

语法

LONG InterlockedAnd(
  [in, out] LONG volatile *Destination,
  [in]      LONG          Value
);

参数

[in, out] Destination

指向第一个操作数的指针。 此值将替换为操作的结果。

[in] Value

第二个操作数。

返回值

函数返回 Destination 参数的原始值。

注解

互锁函数提供了一种简单机制,用于同步对由多个线程共享的变量的访问。 对于对其他互锁函数的调用,此函数是原子的。

对于基于 Intel Itanium 的系统和 x64 体系结构,此函数是使用编译器内部函数实现的。 对于 x86 体系结构,请直接使用 _InterlockedAnd 编译器内部函数。

此函数生成完整的内存屏障 (或围栏) ,以确保按顺序完成内存操作。

基于 Itanium 的系统: 对于性能关键型应用程序,请改用 InterlockedAndAcquireInterlockedAndRelease

注意基于 Windows RT 的系统支持此函数。
 

要求

要求
目标平台 Windows
标头 winnt.h (包括 Windows.h)

另请参阅

互锁变量访问

InterlockedAnd16

InterlockedAnd16Acquire

InterlockedAnd16NoFence

InterlockedAnd16Release

InterlockedAnd64

InterlockedAnd64Acquire

InterlockedAnd64NoFence

InterlockedAnd64Release

InterlockedAnd8

InterlockedAnd8Acquire

InterlockedAnd8NoFence

InterlockedAnd8Release

InterlockedAndAcquire

InterlockedAndNoFence

InterlockedAndRelease

同步函数