Table of Contents

Struct AsyncReaderWriterLockUpgradeableReadToken

Namespace
LfrlAnvil.Async
Assembly
LfrlAnvil.Core.dll

Represents an acquired upgradeable read lock from an AsyncReaderWriterLock instance.

public readonly struct AsyncReaderWriterLockUpgradeableReadToken : IDisposable
Implements
Inherited Members
Extension Methods

Properties

Lock

Associated AsyncReaderWriterLock instance.

public AsyncReaderWriterLock? Lock { get; }

Property Value

AsyncReaderWriterLock

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 AsyncReaderWriterLockUpgradedReadToken TryUpgrade(out bool entered)

Parameters

entered bool

out parameter which specifies whether the upgrade was completed.

Returns

AsyncReaderWriterLockUpgradedReadToken

New AsyncReaderWriterLockUpgradedReadToken value. When entered is 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<AsyncReaderWriterLockUpgradedReadToken> UpgradeAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Optional CancellationToken that can be used to cancel pending upgrade.

Returns

ValueTask<AsyncReaderWriterLockUpgradedReadToken>

New ValueTask<TResult> instance which returns an AsyncReaderWriterLockUpgradedReadToken value.

Exceptions

OperationCanceledException

When provided cancellationToken was 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.