Struct AsyncKeyedReaderWriterLockUpgradeableReadToken<TKey>
Represents an acquired upgradeable read lock from an AsyncKeyedReaderWriterLock<TKey> instance.
public readonly struct AsyncKeyedReaderWriterLockUpgradeableReadToken<TKey> : IDisposable where TKey : notnull
Type Parameters
TKeyKey's type.
- Implements
- Inherited Members
- Extension Methods
Properties
Key
Associated key.
public TKey? Key { get; }
Property Value
- TKey
Lock
Associated AsyncKeyedReaderWriterLock<TKey> instance.
public AsyncKeyedReaderWriterLock<TKey>? Lock { get; }
Property Value
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Exceptions
- InvalidOperationException
When this upgradeable read lock is in the process of being upgraded to a write lock, or has already been upgraded.
TryUpgrade(out bool)
Attempts to synchronously upgrade this lock to a write lock.
public AsyncKeyedReaderWriterLockUpgradedReadToken<TKey> TryUpgrade(out bool entered)
Parameters
enteredboolout parameter which specifies whether the upgrade was completed.
Returns
- AsyncKeyedReaderWriterLockUpgradedReadToken<TKey>
New AsyncKeyedReaderWriterLockUpgradedReadToken<TKey> value. When
enteredis false, then returned instanced will be a default value.
Exceptions
- InvalidOperationException
When this upgradeable read lock has been released, or it's already in the process of being upgraded, or has already been upgraded.
UpgradeAsync(CancellationToken)
Asynchronously upgrades this upgradeable read lock to a write lock.
public ValueTask<AsyncKeyedReaderWriterLockUpgradedReadToken<TKey>> UpgradeAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenOptional CancellationToken that can be used to cancel pending upgrade.
Returns
- ValueTask<AsyncKeyedReaderWriterLockUpgradedReadToken<TKey>>
New ValueTask<TResult> instance which returns an AsyncKeyedReaderWriterLockUpgradedReadToken<TKey> value.
Exceptions
- OperationCanceledException
When provided
cancellationTokenwas cancelled before the upgrade was completed.- InvalidOperationException
When this upgradeable read lock has been released, or it's already in the process of being upgraded, or has already been upgraded.