Skip to content

InterlockedExchange

Exchange 2 integers in a thread-safe way

Declaration

Source position: systemh.inc line 1528

  function InterlockedExchange(var Target: LongInt; Source: LongInt)
                               : LongInt;
  function InterlockedExchange(var Target: Pointer; Source: Pointer)
                               : Pointer;
  function InterlockedExchange(var Target: Cardinal; Source: Cardinal)
                               : Cardinal;

Description

InterLockedExchange stores Source in Target and 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

Name Description
InterlockedCompareExchange Conditional exchange
InterLockedDecrement Thread-safe decrement
InterLockedExchangeAdd Thread-safe add and exchange of 2 values
InterLockedIncrement Thread-safe increment