Skip to content

PgLwLock<T>

Namespace: Ankus

Assembly: Ankus.Runtime.dll

Describes an unmanaged shared value protected by a PostgreSQL lightweight reader/writer lock.

public sealed class PgLwLock<T> where T : unmanaged

Type parameters:

T

The unmanaged value stored in shared memory.

Keep this descriptor in a static field and register it with PgSharedMemory. Each guard belongs to the acquiring callback and backend thread. Recursive acquisition is rejected. Use a using declaration to release a guard promptly; callback exit also releases it. Native addresses embedded in T must be valid across processes, including Windows workers.

Inheritance: object

Creates an unregistered descriptor with a cluster-wide shared-memory name.

public PgLwLock(string name)

Parameters:

name — string

A nonempty, exact UTF-8 name without a zero byte.

Acquires exclusive read/write access, waiting for all other holders to release the lock.

public PgLwLockExclusiveGuard<T> Exclusive()

Returns: PgLwLockExclusiveGuard<T>

A callback-scoped exclusive guard.

Acquires shared read access, waiting for an exclusive writer to release the lock.

public PgLwLockShareGuard<T> Share()

Returns: PgLwLockShareGuard<T>

A callback-scoped shared guard.

Gets the exact name used by PostgreSQL’s shared-memory index and named lock tranche.

public string Name { get; }

Value: string