Show / Hide Table of Contents

Class AsyncReaderWriterLock

Represents asynchronous version of .

Inheritance
Object
QueuedSynchronizer
AsyncReaderWriterLock
Implements
ISynchronizer
Inherited Members
QueuedSynchronizer.ISynchronizer.HasWaiters
QueuedSynchronizer.Dispose(Boolean)
Namespace: DotNext.Threading
Assembly: DotNext.Threading.dll
Syntax
public class AsyncReaderWriterLock : QueuedSynchronizer, ISynchronizer
Remarks

This lock doesn't support recursion.

Constructors

| Improve this Doc View Source

AsyncReaderWriterLock()

Initializes a new reader/writer lock.

Declaration
public AsyncReaderWriterLock()

Properties

| Improve this Doc View Source

CurrentReadCount

Gets the total number of unique readers.

Declaration
public long CurrentReadCount { get; }
Property Value
Type Description
Int64
| Improve this Doc View Source

IsReadLockHeld

Gets a value that indicates whether the read lock taken.

Declaration
public bool IsReadLockHeld { get; }
Property Value
Type Description
Boolean
| Improve this Doc View Source

IsUpgradeableReadLockHeld

Gets a value that indicates whether the current upgradeable read lock taken.

Declaration
public bool IsUpgradeableReadLockHeld { get; }
Property Value
Type Description
Boolean
| Improve this Doc View Source

IsWriteLockHeld

Gets a value that indicates whether the write lock taken.

Declaration
public bool IsWriteLockHeld { get; }
Property Value
Type Description
Boolean

Methods

| Improve this Doc View Source

EnterReadLock(CancellationToken)

Enters the lock in read mode asynchronously.

Declaration
public Task EnterReadLock(CancellationToken token)
Parameters
Type Name Description
CancellationToken token

The token that can be used to abort lock acquisition.

Returns
Type Description
Task

The task representing acquisition operation.

| Improve this Doc View Source

EnterReadLock(TimeSpan)

Enters the lock in read mode asynchronously.

Declaration
public Task EnterReadLock(TimeSpan timeout)
Parameters
Type Name Description
TimeSpan timeout

The interval to wait for the lock.

Returns
Type Description
Task

The task representing acquisition operation.

| Improve this Doc View Source

EnterUpgradeableReadLock(CancellationToken)

Enters the lock in upgradeable mode asynchronously.

Declaration
public Task EnterUpgradeableReadLock(CancellationToken token)
Parameters
Type Name Description
CancellationToken token

The token that can be used to abort lock acquisition.

Returns
Type Description
Task

The task representing lock acquisition operation.

| Improve this Doc View Source

EnterUpgradeableReadLock(TimeSpan)

Enters the lock in upgradeable mode asynchronously.

Declaration
public Task EnterUpgradeableReadLock(TimeSpan timeout)
Parameters
Type Name Description
TimeSpan timeout

The interval to wait for the lock.

Returns
Type Description
Task

The task representing lock acquisition operation.

| Improve this Doc View Source

EnterWriteLock(CancellationToken)

Enters the lock in write mode asynchronously.

Declaration
public Task EnterWriteLock(CancellationToken token)
Parameters
Type Name Description
CancellationToken token

The token that can be used to abort lock acquisition.

Returns
Type Description
Task

The task representing lock acquisition operation.

| Improve this Doc View Source

EnterWriteLock(TimeSpan)

Enters the lock in write mode asynchronously.

Declaration
public Task EnterWriteLock(TimeSpan timeout)
Parameters
Type Name Description
TimeSpan timeout

The interval to wait for the lock.

Returns
Type Description
Task

The task representing lock acquisition operation.

| Improve this Doc View Source

ExitReadLock()

Exits read mode.

Declaration
public void ExitReadLock()
Remarks

Exiting from the lock is synchronous non-blocking operation. Lock acquisition is an asynchronous operation.

| Improve this Doc View Source

ExitUpgradeableReadLock()

Exits upgradeable mode.

Declaration
public void ExitUpgradeableReadLock()
Remarks

Exiting from the lock is synchronous non-blocking operation. Lock acquisition is an asynchronous operation.

| Improve this Doc View Source

ExitWriteLock()

Exits write mode.

Declaration
public void ExitWriteLock()
Remarks

Exiting from the lock is synchronous non-blocking operation. Lock acquisition is an asynchronous operation.

| Improve this Doc View Source

TryEnterReadLock()

Attempts to obtain reader lock synchronously without blocking caller thread.

Declaration
public bool TryEnterReadLock()
Returns
Type Description
Boolean

true if lock is taken successfuly; otherwise, false.

| Improve this Doc View Source

TryEnterReadLock(TimeSpan)

Tries to enter the lock in read mode asynchronously, with an optional time-out.

Declaration
public Task<bool> TryEnterReadLock(TimeSpan timeout)
Parameters
Type Name Description
TimeSpan timeout

The interval to wait for the lock.

Returns
Type Description
Task<Boolean>

true if the caller entered read mode; otherwise, false.

| Improve this Doc View Source

TryEnterReadLock(TimeSpan, CancellationToken)

Tries to enter the lock in read mode asynchronously, with an optional time-out.

Declaration
public Task<bool> TryEnterReadLock(TimeSpan timeout, CancellationToken token)
Parameters
Type Name Description
TimeSpan timeout

The interval to wait for the lock.

CancellationToken token

The token that can be used to abort lock acquisition.

Returns
Type Description
Task<Boolean>

true if the caller entered read mode; otherwise, false.

| Improve this Doc View Source

TryEnterUpgradeableReadLock()

Attempts to obtain upgradeable reader lock synchronously without blocking caller thread.

Declaration
public bool TryEnterUpgradeableReadLock()
Returns
Type Description
Boolean

true if lock is taken successfuly; otherwise, false.

| Improve this Doc View Source

TryEnterUpgradeableReadLock(TimeSpan)

Tries to enter the lock in upgradeable mode asynchronously, with an optional time-out.

Declaration
public Task<bool> TryEnterUpgradeableReadLock(TimeSpan timeout)
Parameters
Type Name Description
TimeSpan timeout

The interval to wait for the lock.

Returns
Type Description
Task<Boolean>

true if the caller entered upgradeable mode; otherwise, false.

| Improve this Doc View Source

TryEnterUpgradeableReadLock(TimeSpan, CancellationToken)

Tries to enter the lock in upgradeable mode asynchronously, with an optional time-out.

Declaration
public Task<bool> TryEnterUpgradeableReadLock(TimeSpan timeout, CancellationToken token)
Parameters
Type Name Description
TimeSpan timeout

The interval to wait for the lock.

CancellationToken token

The token that can be used to abort lock acquisition.

Returns
Type Description
Task<Boolean>

true if the caller entered upgradeable mode; otherwise, false.

| Improve this Doc View Source

TryEnterWriteLock()

Attempts to obtain writer lock synchronously without blocking caller thread.

Declaration
public bool TryEnterWriteLock()
Returns
Type Description
Boolean

true if lock is taken successfuly; otherwise, false.

| Improve this Doc View Source

TryEnterWriteLock(AsyncReaderWriterLock.LockStamp)

Attempts to acquire write lock without blocking.

Declaration
public bool TryEnterWriteLock(in AsyncReaderWriterLock.LockStamp stamp)
Parameters
Type Name Description
AsyncReaderWriterLock.LockStamp stamp

The stamp of the read lock.

Returns
Type Description
Boolean

true if lock is acquired successfully; otherwise, false.

| Improve this Doc View Source

TryEnterWriteLock(TimeSpan)

Tries to enter the lock in write mode asynchronously, with an optional time-out.

Declaration
public Task<bool> TryEnterWriteLock(TimeSpan timeout)
Parameters
Type Name Description
TimeSpan timeout

The interval to wait for the lock.

Returns
Type Description
Task<Boolean>

true if the caller entered write mode; otherwise, false.

| Improve this Doc View Source

TryEnterWriteLock(TimeSpan, CancellationToken)

Tries to enter the lock in write mode asynchronously, with an optional time-out.

Declaration
public Task<bool> TryEnterWriteLock(TimeSpan timeout, CancellationToken token)
Parameters
Type Name Description
TimeSpan timeout

The interval to wait for the lock.

CancellationToken token

The token that can be used to abort lock acquisition.

Returns
Type Description
Task<Boolean>

true if the caller entered write mode; otherwise, false.

| Improve this Doc View Source

TryOptimisticRead()

Returns a stamp that can be validated later.

Declaration
public AsyncReaderWriterLock.LockStamp TryOptimisticRead()
Returns
Type Description
AsyncReaderWriterLock.LockStamp

Optimistic read stamp. May be invalid.

Implements

ISynchronizer

Extension Methods

AsyncLockAcquisition.AcquireLockAsync<T>(T, TimeSpan)
AsyncLockAcquisition.AcquireLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, TimeSpan)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, TimeSpan)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireUpgradeableReadLockAsync<T>(T, TimeSpan)
AsyncLockAcquisition.AcquireUpgradeableReadLockAsync<T>(T, CancellationToken)
ExpressionBuilder.Const<T>(T)
ObjectExtensions.GetUserData<T>(T)
ObjectExtensions.IsOneOf<T>(T, IEnumerable<T>)
ObjectExtensions.IsOneOf<T>(T, T[])
ObjectExtensions.Decompose<T, R1, R2>(T, Func<T, R1>, Func<T, R2>, out R1, out R2)
ObjectExtensions.Decompose<T, R1, R2>(T, ValueFunc<T, R1>, ValueFunc<T, R2>, out R1, out R2)
ObjectExtensions.Decompose<T, R1, R2>(T, Func<T, R1>, Func<T, R2>)
ObjectExtensions.Decompose<T, R1, R2>(T, ValueFunc<T, R1>, ValueFunc<T, R2>)
LockAcquisition.AcquireReadLock<T>(T)
LockAcquisition.AcquireReadLock<T>(T, TimeSpan)
LockAcquisition.AcquireWriteLock<T>(T)
LockAcquisition.AcquireWriteLock<T>(T, TimeSpan)
LockAcquisition.AcquireUpgradeableReadLock<T>(T)
LockAcquisition.AcquireUpgradeableReadLock<T>(T, TimeSpan)
  • Improve this Doc
  • View Source
Back to top Generated by DocFX