Unit 'System' Package
[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] [#rtl]

InterlockedCompareExchange

Conditional exchange.

Declaration

Source position: systemh.inc line 1606

function InterlockedCompareExchange(

  var Target: LongInt;

  NewValue: LongInt;

  Comperand: LongInt

):LongInt;

function InterlockedCompareExchange(

  var Target: Pointer;

  NewValue: Pointer;

  Comperand: Pointer

):Pointer;

function InterlockedCompareExchange(

  var Target: Cardinal;

  NewValue: Cardinal;

  Comperand: Cardinal

):Cardinal;

Description

InterlockedCompareExchange does an compare-and-exchange operation on the specified values in a thread-safe way. The function compares Target and Comperand and exchanges Target with NewValue if Target and Comperand are equal. It returns the old value of Target. This is done in a thread-safe way, i.e., only one processor is accessing the Target variable at a time.

Errors

None.

See also

InterLockedDecrement

  

Thread-safe decrement.

InterLockedIncrement

  

Thread-safe increment.

InterLockedExchange

  

Exchange 2 integers in a thread-safe way.

InterLockedExchangeAdd

  

Thread-safe add and exchange of 2 values.


Documentation generated on: Jul 24 2023