Important: The information in this document is obsolete and should not be used for new development.
OTCompareAndSwapPtr
Atomically compares the value of a pointer at a memory location and atomically swaps it with a second pointer value if the compare is successful.C INTERFACE
Boolean OTCompareAndSwapPtr( void* oldVal, void* newVal, void** where)C++ INTERFACE
None. C++ applications use the C interface to this function.PARAMETERS
oldVal- The pointer being compared to the pointer referenced by the
whereparameter.
newVal- The value to be assigned to the pointer referenced by the
whereparameter.
where- A reference to the pointer being compared to the pointer specified by the
oldValparameter.- function result
- Returns
trueif the swap is done.DISCUSSION
This function compares the value specified by theoldValparameter with the value referenced by thewhereparameter. If the two values are the same, the function replaces the values referenced by thewhereparameter with the value specified by thenewValparameter and it returnstrue. If the two values are not the same, no swap occurs and the function returnsfalse.The entire compare and swap operation is atomic.
Use the
- WARNING
- The pointer
wheremust be on a 4-byte boundary, or calling this function may hang the machine.
OTCompareAndSwap32function to compare two 32-bit values and set one if they are the same.
 
  
  
  