System.AtomicCmpExchange

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function AtomicCmpExchange(var Target; NewValue: <Integer or NativeInt or Pointer>; Comparand: <Integer or NativeInt or Pointer>; [out Succeeded: Boolean]): Integer; overload;
function AtomicCmpExchange(var Target; NewValue: <Integer or NativeInt or Pointer>; Comparand: <Integer or NativeInt or Pointer>; [out Succeeded: Boolean]): Int64; overload;
function AtomicCmpExchange(var Target; NewValue: <Integer or NativeInt or Pointer>; Comparand: <Integer or NativeInt or Pointer>; [out Succeeded: Boolean]): Pointer; overload;
function AtomicCmpExchange(var Target; NewValue: <Integer or NativeInt or Pointer>; Comparand: <Integer or NativeInt or Pointer>; [out Succeeded: Boolean]): NativeInt; overload;
function AtomicCmpExchange(var Target; NewValue: <Integer or NativeInt or Pointer>; Comparand: <Integer or NativeInt or Pointer>; [out Succeeded: Boolean]): Integer; overload;
function AtomicCmpExchange(var Target; NewValue: <Integer or NativeInt or Pointer>; Comparand: <Integer or NativeInt or Pointer>; [out Succeeded: Boolean]): Int64; overload;
function AtomicCmpExchange(var Target; NewValue: <Integer or NativeInt or Pointer>; Comparand: <Integer or NativeInt or Pointer>; [out Succeeded: Boolean]): Pointer; overload;
function AtomicCmpExchange(var Target; NewValue: <Integer or NativeInt or Pointer>; Comparand: <Integer or NativeInt or Pointer>; [out Succeeded: Boolean]): NativeInt; overload;

Properties

Type Visibility Source Unit Parent
function public System.pas System System

Description

Atomic intrinsic Compare and Exchange function for use with Delphi mobile compilers. Compares the contents of the target to a given value (comparand) and, only if they are the same, modifies the contents of target to the new value.

Because the Delphi mobile compilers do not support a built-in assembler, the System unit provides four atomic intrinsic functions that provide a way to atomically exchange, compare and exchange, increment, and decrement memory values.

AtomicCmpExchange is used for comparing and exchanging memory values.

Atomic operations are used to:

  • Implement multi-threaded locking primitives
  • Provide the primitives necessary for implementing so-called "lock-free" structures

See Also