PgAtomic<T>
Namespace: Ankus
Assembly: Ankus.Runtime.dll
Stores one atomic scalar in PostgreSQL shared memory for use across processes and managed threads.
public sealed class PgAtomic<T> where T : unmanagedType parameters:
T
A primitive or enum type supported by Interlocked.
Keep the descriptor in a static field and register it with PgSharedMemory during shared preload. Operations use the strong ordering of .NET Interlocked and do not invoke PostgreSQL. Each operation protects its address against shared-memory retirement. Values survive transaction errors but are initialized again when PostgreSQL recreates shared memory.
Inheritance: object
Constructors
Section titled “Constructors”PgAtomic(string)
Section titled “PgAtomic(string)”Creates an unregistered atomic descriptor with a cluster-wide shared-memory name.
public PgAtomic(string name)Parameters:
name — string
A nonempty, exact UTF-8 name without a zero byte.
Exceptions:
- NotSupportedException: T is not a supported primitive or enum type.
Methods
Section titled “Methods”CompareExchange(T, T)
Section titled “CompareExchange(T, T)”Atomically replaces the scalar when its bits equal the comparand and returns the previous value.
public T CompareExchange(T value, T comparand)Parameters:
value — T
The replacement value when comparison succeeds.
comparand — T
The exact bit pattern required for replacement.
Returns: T
The value before comparison, whether or not replacement occurred.
Exchange(T)
Section titled “Exchange(T)”Atomically replaces the scalar and returns its previous value.
public T Exchange(T value)Parameters:
value — T
The replacement value.
Returns: T
The value before replacement.
Properties
Section titled “Properties”Gets the exact cluster-wide shared-memory name.
public string Name { get; }Value: string
Gets or replaces the scalar atomically, preserving its exact bits.
public T Value { get; set; }Value: T