PgShared<T>
Namespace: Ankus
Assembly: Ankus.Runtime.dll
Stores an unmanaged aggregate with immutable, atomic or spinlock-protected fields in PostgreSQL shared memory.
public sealed class PgShared<T> where T : unmanagedType parameters:
T
The unmanaged shared value.
Register a static descriptor during shared preload. Ordinary fields are immutable after initialization; use inline atomic values or spinlocks for concurrent updates. Embedded addresses must be valid in every process. Each synchronous read protects the native address against retirement until its callback returns.
Inheritance: object
Constructors
Section titled “Constructors”PgShared(string)
Section titled “PgShared(string)”Creates an unregistered shared-value descriptor with a cluster-wide name.
public PgShared(string name)Parameters:
name — string
A nonempty, exact UTF-8 name without a zero byte.
Properties
Section titled “Properties”Gets the exact cluster-wide shared-memory name.
public string Name { get; }Value: string
Methods
Section titled “Methods”Read<TResult>(PgSharedReader<T, TResult>)
Section titled “Read<TResult>(PgSharedReader<T, TResult>)”Invokes a synchronous reader while protecting the current shared segment from retirement.
public TResult Read<TResult>(PgSharedReader<T, TResult> reader)Type parameters:
TResult
The owned callback result.
Parameters:
reader — PgSharedReader<T, TResult>
The reader, whose shared reference cannot escape the callback.
Returns: TResult
The callback result.
Access inline atomic fields directly through the readonly reference. Copying the aggregate or a field copies its state and subsequent updates affect that copy. Multiple atomic fields do not form a single transaction. Keep callbacks finite; shutdown waits for admitted readers to finish. Access inline spinlocks directly through this reference on the backend callback thread. Guards are released before the read returns, including exceptional exits, and cannot escape its admission.