System.SyncObjs.TInterlocked.CompareExchange
Delphi
class function CompareExchange(var Target: Pointer; Value: Pointer; Comparand: Pointer): Pointer; overload; static; inline;
class function CompareExchange(var Target: Integer; Value: Integer; Comparand: Integer): Integer; overload; static; inline;
class function CompareExchange(var Target: Integer; Value: Integer; Comparand: Integer; out Succeeded: Boolean): Integer; overload; static;
class function CompareExchange(var Target: Int64; Value: Int64; Comparand: Int64): Int64; overload; static; inline;
class function CompareExchange(var Target: TObject; Value: TObject; Comparand: TObject): TObject; overload; static; inline;
class function CompareExchange(var Target: Double; Value: Double; Comparand: Double): Double; overload; static; inline;
class function CompareExchange(var Target: Single; Value: Single; Comparand: Single): Single; overload; static; inline;
class function CompareExchange<T: class>(var Target: T; Value: T; Comparand: T): T; overload; static; inline;
C++
static void * __fastcall CompareExchange(void * &Target, void * Value, void * Comparand)/* overload */;
static int __fastcall CompareExchange(int &Target, int Value, int Comparand)/* overload */;
static int __fastcall CompareExchange(int &Target, int Value, int Comparand, /* out */ bool &Succeeded)/* overload */;
static __int64 __fastcall CompareExchange(__int64 &Target, __int64 Value, __int64 Comparand)/* overload */;
static System::TObject* __fastcall CompareExchange(System::TObject* &Target, System::TObject* Value, System::TObject* Comparand)/* overload */;
static double __fastcall CompareExchange(double &Target, double Value, double Comparand)/* overload */;
static float __fastcall CompareExchange(float &Target, float Value, float Comparand)/* overload */;
template<typename T> static T __fastcall CompareExchange(T &Target, T Value, T Comparand)/* overload */;
Propriétés
| Type | Visibilité | Source | Unité | Parent |
|---|---|---|---|---|
| function | public | System.SyncObjs.pas System.SyncObjs.hpp |
System.SyncObjs | TInterlocked |
Description
Compare le contenu de Target et Comparand et si les valeurs sont égales, la fonction modifie le contenu de Target.
CompareExchange compare la valeur Target à la valeur Comparand. Si la valeur Target est égale à la valeur Comparand, alors la valeur Value est stockée à l'adresse spécifiée par Target. Dans le cas contraire, aucune opération n'est effectuée.
Il existe huit surcharges de CompareExchange. L'une d'entre elles accepte le paramètre supplémentaire Succeeded. Ce paramètre obtient la valeur True si l'opération réussit, ou la valeur False dans le cas contraire.
La dernière méthode a des paramètres génériques ainsi qu'un type de retour générique, et elle peut également recevoir des paramètres de tout type d'objet.