Struct AsyncKeyedLock<TKey>.Releaser
- Namespace
- CryptoHives.Foundation.Threading.Async.Pooled
- Assembly
- CryptoHives.Foundation.Threading.dll
A small value type returned by awaiting a lock acquisition. Disposing the releaser releases the lock for Key.
public readonly struct AsyncKeyedLock<TKey>.Releaser : IDisposable, IAsyncDisposable, IEquatable<AsyncKeyedLock<TKey>.Releaser>
- Implements
- Inherited Members
Remarks
A releaser identifies one specific acquisition, not merely the key: because entries are reused across acquisitions, it carries a generation token stamped when the lock was taken - the same technique ValueTask<TResult> uses to tell a live result apart from a recycled source. Disposing a releaser whose token no longer matches throws rather than releasing somebody else's hold.
Properties
Key
Gets the key this releaser will unlock when disposed.
public TKey Key { get; }
Property Value
- TKey
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Exceptions
- InvalidOperationException
Thrown when this releaser has already been disposed, or otherwise no longer represents the acquisition that is currently holding the lock for Key.
DisposeAsync()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.
public ValueTask DisposeAsync()
Returns
Equals(Releaser)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(AsyncKeyedLock<TKey>.Releaser other)
Parameters
otherAsyncKeyedLock<TKey>.ReleaserAn object to compare with this object.
Returns
- bool
true if the current object is equal to the
otherparameter; otherwise, false.
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand this instance are the same type and represent the same value; otherwise, false.
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
Operators
operator ==(Releaser, Releaser)
Determines whether two AsyncKeyedLock<TKey>.Releaser instances are equal.
public static bool operator ==(AsyncKeyedLock<TKey>.Releaser left, AsyncKeyedLock<TKey>.Releaser right)
Parameters
leftAsyncKeyedLock<TKey>.ReleaserThe first Releaser to compare.
rightAsyncKeyedLock<TKey>.ReleaserThe second Releaser to compare.
Returns
- bool
true if the specified Releaser instances are equal; otherwise, false.
operator !=(Releaser, Releaser)
Determines whether two AsyncKeyedLock<TKey>.Releaser instances are not equal.
public static bool operator !=(AsyncKeyedLock<TKey>.Releaser left, AsyncKeyedLock<TKey>.Releaser right)
Parameters
leftAsyncKeyedLock<TKey>.ReleaserThe first Releaser to compare.
rightAsyncKeyedLock<TKey>.ReleaserThe second Releaser to compare.
Returns
- bool
false if the specified Releaser instances are equal; otherwise, true.