Skip to content

PgAtomicValue<T>

Namespace: Ankus

Assembly: Ankus.Runtime.dll

Embeds one atomic scalar in an unmanaged shared aggregate.

public readonly struct PgAtomicValue<T> where T : unmanaged

Type parameters:

T

A primitive or enum type supported by Interlocked.

Operate directly on a field of the readonly reference supplied by a shared reader. Copying this value copies its current storage, not its identity. Each value occupies eight bytes and must be eight-byte aligned; packed unaligned layouts are rejected. Operations use Interlocked ordering.

Creates an inline atomic scalar with the supplied bits.

public PgAtomicValue(T value)

Parameters:

value — T

The initial scalar.

Replaces the scalar when its bits match the comparand and returns its previous value.

public T CompareExchange(T value, T comparand)

Parameters:

value — T

The replacement value when comparison succeeds.

comparand — T

The exact required bit pattern.

Returns: T

The value before comparison, whether or not replacement occurred.

Atomically replaces the scalar and returns its previous value.

public T Exchange(T value)

Parameters:

value — T

The replacement value.

Returns: T

The value before replacement.

Gets the scalar atomically without copying its containing storage.

public T Value { get; }

Value: T