Skip to content

PgLwLockShareGuard<T>

Namespace: Ankus

Assembly: Ankus.Runtime.dll

Holds shared read access to a PostgreSQL shared-memory value until disposal or callback exit.

public sealed class PgLwLockShareGuard<T> : IDisposable where T : unmanaged

Type parameters:

T

The unmanaged shared value.

Inheritance: object

Implements: IDisposable

Releases this guard once without modifying the shared value.

public void Dispose()

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. Disposing this guard and calling backend APIs are rejected while a reader is active, so PostgreSQL cannot release its lock beneath the borrowed reference.

Gets a copy of the shared value while this guard holds the lock.

public T Value { get; }

Value: T