System.AtomicCmpExchange

提供: RAD Studio API Documentation
移動先: 案内検索

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;

プロパティ

種類 可視性 ソース ユニット
function public System.pas System System


説明

Delphi モバイル コンパイラ用のアトミックな組み込み比較および交換関数です。Target の内容を指定の値(Comparand)と比較し、両者が同じ場合にのみ、Target の内容を新しい値に変更します。

この関数は、常に Target の元の値を返します。Succeeded パラメータが指定された場合、Succeeded は、値の交換が行われれば(TargetNewValue が同じ場合も含む)True に、行われなければ False になります。

Delphi モバイル コンパイラでは組み込みアセンブラをサポートしていないため、System ユニットには、メモリ値の交換、比較および交換、インクリメント、デクリメントをアトミックに行う手段となる 4 つのアトミックな組み込み関数が用意されています。

AtomicCmpExchange はメモリ値の比較および交換に使用されます。

アトミック操作は以下の目的に使用されます。

  • マルチスレッド ロック プリミティブの実装
  • いわゆる "ロックフリー" 構造の実装に必要なプリミティブの提供

関連項目