final class · System.Threading
AtomicI32
public final class AtomicI32
An i32 that threads change together (each operation is atomic). Add, Increment and Decrement give the new value, Exchange and CompareExchange the old one.
- Tipo
- final class
- Espacio de nombres
- System.Threading
- Ensamblado
- System.Core
- Acceso
- public, final
- Archivo fuente
Threading.ant
Herencia
- Clases base
-
AnyAtomicI32
Constructores
Propiedades
Métodos
Sets v if the value is comparand: the value before.
Miembros privados e internos (6)
Miembros heredados (5)
GetTypemétodo de AnyUndescribedmétodo de AnyToStringmétodo de AnyHashmétodo de Anydestroymétodo de Any
Código fuente
AtomicI32 en Antril, descompilado a partir de su Larva HIR.
// System.Threading.AtomicI32 — System.Core (decompiled from Larva HIR)
into namespace System.Threading
{
/// An i32 that threads change together (each operation is atomic). Add, Increment and Decrement give the new value,
/// Exchange and CompareExchange the old one.
public final class AtomicI32
{
i32 value;
static unsafe extern("atomic.load.i32") LoadAt(i32* at) : i32;
static unsafe extern("atomic.store.i32") StoreAt(i32* at, i32 value);
static unsafe extern("atomic.add.i32") AddAt(i32* at, i32 value) : i32;
static unsafe extern("atomic.xchg.i32") ExchangeAt(i32* at, i32 value) : i32;
static unsafe extern("atomic.cas.i32") CompareAt(i32* at, i32 expected, i32 value) : i32;
public:
new()
{
}
new(i32 value)
{
this.value = value;
}
Load() : i32
{
unsafe
{
return LoadAt(&value);
}
}
Store(i32 v)
{
unsafe
{
StoreAt(&value, v);
}
}
Add(i32 delta) : i32
{
unsafe
{
return AddAt(&value, delta) + delta;
}
}
Increment() : i32
{
unsafe
{
return AddAt(&value, 1) + 1;
}
}
Decrement() : i32
{
unsafe
{
return AddAt(&value, -1) - 1;
}
}
Exchange(i32 v) : i32
{
unsafe
{
return ExchangeAt(&value, v);
}
}
/// Sets `v` if the value is `comparand`: the value before.
CompareExchange(i32 v, i32 comparand) : i32
{
unsafe
{
return CompareAt(&value, comparand, v);
}
}
i32 Value
{
get => Load();
set
{
Store(value);
}
}
}
}