Skip to content

PgSpinLock<T>

Namespace: Ankus

Assembly: Ankus.Runtime.dll

Owns stable local storage for a value protected by a PostgreSQL spinlock.

public sealed class PgSpinLock<T> where T : unmanaged

Type parameters:

T

The unmanaged protected value.

This local owner pins its storage for its managed lifetime. Use PgSpinLockValue inside PgShared for cross-process storage. Construction and access require the owning backend’s native callback. Prefer PgLwLock for work longer than a few instructions.

Inheritance: object

Creates stable local storage and initializes its selected-header native spinlock.

public PgSpinLock(T value)

Parameters:

value — T

The initial protected value.

Gets an instantaneous lock-state observation on PostgreSQL versions before 19.

public bool IsLocked { get; }

Value: bool

Acquires exclusive access until disposal or callback exit.

public PgSpinLockGuard<T> Lock()

Returns: PgSpinLockGuard<T>

The checked guard, which keeps this owner’s storage alive.