次の方法で共有


InterlockedCompareExchangePointer (Compact 2013)

3/28/2014

This function performs an atomic comparison of the specified parameter values and exchanges the values based on the outcome of the comparison. More than one thread cannot use the same variable simultaneously.

If you are exchanging pointer values, this function supersedes InterlockedCompareExchange.

Syntax

PVOID InterlockedCompareExchangePointer(
  PVOID* Destination,
  PVOID ExChange,
  PVOID Comperand
);

Parameters

  • Destination
    [in/out] Pointer to the pointer to the destination value. The sign is ignored.
  • ExChange
    [in] Exchange value. The sign is ignored.
  • Comperand
    [in] Value to compare to Destination. The sign is ignored.

Return Value

Initial value of the destination.

Remarks

The interlocked functions provide a simple mechanism for synchronizing access to a variable that is shared by multiple threads. The threads of different processes can use this mechanism, if the variable is in shared memory.

InterlockedCompareExchange performs an atomic comparison of the Destinationvalue with the Comperandvalue. If the Destinationvalue is equal to the Comperandvalue, the ExChangevalue is stored in the address specified by Destination. Otherwise, no operation is performed.

Requirements

Header

winbase.h

Library

coredll.lib

See Also

Reference

Synchronization Functions
InterlockedCompareExchange