PgLwLockExclusiveGuard<T>
Namespace: Ankus
Assembly: Ankus.Runtime.dll
Holds exclusive read/write access to a PostgreSQL shared-memory value until disposal or callback exit.
public sealed class PgLwLockExclusiveGuard<T> : IDisposable where T : unmanagedType parameters:
T
The unmanaged shared value.
Inheritance: object
Implements: IDisposable
Methods
Section titled “Methods”Dispose()
Section titled “Dispose()”Releases this guard once, preserving any value already written.
public void Dispose()Mutate<TResult>(PgSharedMutator<T, TResult>)
Section titled “Mutate<TResult>(PgSharedMutator<T, TResult>)”Mutates original protected storage through a reference limited to the synchronous callback.
public TResult Mutate<TResult>(PgSharedMutator<T, TResult> mutator)Type parameters:
TResult
The owned callback result.
Parameters:
mutator — PgSharedMutator<T, TResult>
The update, whose protected reference cannot escape the callback.
Returns: TResult
The callback result.
Writes remain visible if the callback throws or the SQL transaction rolls back. Value can return a copy, but aliases cannot borrow original storage, replace Value or dispose this guard while the callback is active. Nested spinlock access and backend calls are rejected. Use a separate Read callback for nested locks while retaining the same parent guard.
Read<TResult>(PgSharedReader<T, TResult>)
Section titled “Read<TResult>(PgSharedReader<T, TResult>)”Reads original protected storage through a reference limited to the synchronous callback.
public TResult Read<TResult>(PgSharedReader<T, TResult> reader)Type parameters:
TResult
The owned callback result.
Parameters:
reader — PgSharedReader<T, TResult>
The reader, whose readonly reference cannot escape the callback.
Returns: TResult
The callback result.
Access nested atomic and spinlock fields directly through this reference. Child spinlock guards expire before the read ends. Replacing Value, disposing this guard and calling backend APIs are rejected while a reader is active. Value can still return a copy during the read.
Properties
Section titled “Properties”Gets or sets a copy of the shared value while this guard holds the lock.
public T Value { get; set; }Value: T
Writes take effect immediately and are not rolled back by a transaction abort or exception. Read the value, modify the copy, then assign it back to publish a complete update.