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
IsHeldboolWhether a lease holds the lock: the item has an owner. A released lock, and one whose holder released it, is not held.
HolderLabelstringThe HolderLabel of the holder, or null without one, and while the lock is free.
LeaseDurationTimeSpan?The lease of the holder, in whole milliseconds as stored, or null while the lock is free.
FencingTokenlongThe 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
HolderLabel
The HolderLabel of the holder, or null without one, and while the lock is free.
public string? HolderLabel { get; init; }
Property Value
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
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
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
Equals(LockState?)
public bool Equals(LockState? other)
Parameters
otherLockState
Returns
Equals(object?)
public override bool Equals(object? obj)
Parameters
objobject
Returns
GetHashCode()
public override int GetHashCode()
Returns
ToString()
public override string ToString()
Returns
Operators
operator ==(LockState?, LockState?)
public static bool operator ==(LockState? left, LockState? right)
Parameters
Returns
operator !=(LockState?, LockState?)
public static bool operator !=(LockState? left, LockState? right)