Table of Contents

Class LockState

Namespace
DynaSharp.Coordination.Testing
Assembly
DynaSharp.Coordination.dll

What the item of a lock says, as GetStateAsync(LockTable, string, CancellationToken) reads it, so a test asserts on a lock without knowing the format of its item. A record, so a test compares it with one it builds: new LockState(IsHeld: true, HolderLabel: "pod-a", LeaseDuration: TimeSpan.FromSeconds(30), FencingToken: 2).

public sealed record LockState : IEquatable<LockState>
Inheritance
LockState
Implements
Inherited Members

Constructors

LockState(bool, string?, TimeSpan?, long)

What the item of a lock says, as GetStateAsync(LockTable, string, CancellationToken) reads it, so a test asserts on a lock without knowing the format of its item. A record, so a test compares it with one it builds: new LockState(IsHeld: true, HolderLabel: "pod-a", LeaseDuration: TimeSpan.FromSeconds(30), FencingToken: 2).

public LockState(bool IsHeld, string? HolderLabel, TimeSpan? LeaseDuration, long FencingToken)

Parameters

IsHeld bool

Whether a lease holds the lock: the item has an owner. A released lock, and one whose holder released it, is not held.

HolderLabel string

The HolderLabel of the holder, or null without one, and while the lock is free.

LeaseDuration TimeSpan?

The lease of the holder, in whole milliseconds as stored, or null while the lock is free.

FencingToken long

The fencing token of the last acquire, which a release keeps: 1 after the first acquire, 0 for an item that no acquire wrote.

Properties

FencingToken

The fencing token of the last acquire, which a release keeps: 1 after the first acquire, 0 for an item that no acquire wrote.

public long FencingToken { get; init; }

Property Value

long

HolderLabel

The HolderLabel of the holder, or null without one, and while the lock is free.

public string? HolderLabel { get; init; }

Property Value

string

IsHeld

Whether a lease holds the lock: the item has an owner. A released lock, and one whose holder released it, is not held.

public bool IsHeld { get; init; }

Property Value

bool

LeaseDuration

The lease of the holder, in whole milliseconds as stored, or null while the lock is free.

public TimeSpan? LeaseDuration { get; init; }

Property Value

TimeSpan?

Methods

Deconstruct(out bool, out string?, out TimeSpan?, out long)

public void Deconstruct(out bool IsHeld, out string? HolderLabel, out TimeSpan? LeaseDuration, out long FencingToken)

Parameters

IsHeld bool
HolderLabel string
LeaseDuration TimeSpan?
FencingToken long

Equals(LockState?)

public bool Equals(LockState? other)

Parameters

other LockState

Returns

bool

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

GetHashCode()

public override int GetHashCode()

Returns

int

ToString()

public override string ToString()

Returns

string

Operators

operator ==(LockState?, LockState?)

public static bool operator ==(LockState? left, LockState? right)

Parameters

left LockState
right LockState

Returns

bool

operator !=(LockState?, LockState?)

public static bool operator !=(LockState? left, LockState? right)

Parameters

left LockState
right LockState

Returns

bool