Class AsyncLockAcquisition
Provides a set of methods to acquire different types of asynchronous lock.
Namespace: DotNext.Threading
Assembly: DotNext.Threading.dll
Syntax
public static class AsyncLockAcquisition : object
Methods
| Improve this Doc View SourceAcquireLockAsync<T>(T, CancellationToken)
Acquires exclusive lock associated with the given object.
Declaration
public static Task<AsyncLock.Holder> AcquireLockAsync<T>(this T obj, CancellationToken token)
where T : class
Parameters
Type | Name | Description |
---|---|---|
T | obj | The object to be locked. |
CancellationToken | token | The token that can be used to abort acquisition operation. |
Returns
Type | Description |
---|---|
Task<AsyncLock.Holder> | The acquired lock holder. |
Type Parameters
Name | Description |
---|---|
T | The type of the object to be locked. |
AcquireLockAsync<T>(T, TimeSpan)
Acquires exclusive lock associated with the given object.
Declaration
public static Task<AsyncLock.Holder> AcquireLockAsync<T>(this T obj, TimeSpan timeout)
where T : class
Parameters
Type | Name | Description |
---|---|---|
T | obj | The object to be locked. |
TimeSpan | timeout | The interval to wait for the lock. |
Returns
Type | Description |
---|---|
Task<AsyncLock.Holder> | The acquired lock holder. |
Type Parameters
Name | Description |
---|---|
T | The type of the object to be locked. |
AcquireReadLockAsync<T>(T, CancellationToken)
Acquires reader lock associated with the given object.
Declaration
public static Task<AsyncLock.Holder> AcquireReadLockAsync<T>(this T obj, CancellationToken token)
where T : class
Parameters
Type | Name | Description |
---|---|---|
T | obj | The object to be locked. |
CancellationToken | token | The token that can be used to abort acquisition operation. |
Returns
Type | Description |
---|---|
Task<AsyncLock.Holder> | The acquired lock holder. |
Type Parameters
Name | Description |
---|---|
T | The type of the object to be locked. |
AcquireReadLockAsync<T>(T, TimeSpan)
Acquires reader lock associated with the given object.
Declaration
public static Task<AsyncLock.Holder> AcquireReadLockAsync<T>(this T obj, TimeSpan timeout)
where T : class
Parameters
Type | Name | Description |
---|---|---|
T | obj | The object to be locked. |
TimeSpan | timeout | The interval to wait for the lock. |
Returns
Type | Description |
---|---|
Task<AsyncLock.Holder> | The acquired lock holder. |
Type Parameters
Name | Description |
---|---|
T | The type of the object to be locked. |
AcquireUpgradeableReadLockAsync<T>(T, CancellationToken)
Acquires upgradeable lock associated with the given object.
Declaration
public static Task<AsyncLock.Holder> AcquireUpgradeableReadLockAsync<T>(this T obj, CancellationToken token)
where T : class
Parameters
Type | Name | Description |
---|---|---|
T | obj | The object to be locked. |
CancellationToken | token | The token that can be used to abort acquisition operation. |
Returns
Type | Description |
---|---|
Task<AsyncLock.Holder> | The acquired lock holder. |
Type Parameters
Name | Description |
---|---|
T | The type of the object to be locked. |
AcquireUpgradeableReadLockAsync<T>(T, TimeSpan)
Acquires upgradeable lock associated with the given object.
Declaration
public static Task<AsyncLock.Holder> AcquireUpgradeableReadLockAsync<T>(this T obj, TimeSpan timeout)
where T : class
Parameters
Type | Name | Description |
---|---|---|
T | obj | The object to be locked. |
TimeSpan | timeout | The interval to wait for the lock. |
Returns
Type | Description |
---|---|
Task<AsyncLock.Holder> | The acquired lock holder. |
Type Parameters
Name | Description |
---|---|
T | The type of the object to be locked. |
AcquireWriteLockAsync<T>(T, CancellationToken)
Acquires reader lock associated with the given object.
Declaration
public static Task<AsyncLock.Holder> AcquireWriteLockAsync<T>(this T obj, CancellationToken token)
where T : class
Parameters
Type | Name | Description |
---|---|---|
T | obj | The object to be locked. |
CancellationToken | token | The token that can be used to abort acquisition operation. |
Returns
Type | Description |
---|---|
Task<AsyncLock.Holder> | The acquired lock holder. |
Type Parameters
Name | Description |
---|---|
T | The type of the object to be locked. |
AcquireWriteLockAsync<T>(T, TimeSpan)
Acquires writer lock associated with the given object.
Declaration
public static Task<AsyncLock.Holder> AcquireWriteLockAsync<T>(this T obj, TimeSpan timeout)
where T : class
Parameters
Type | Name | Description |
---|---|---|
T | obj | The object to be locked. |
TimeSpan | timeout | The interval to wait for the lock. |
Returns
Type | Description |
---|---|
Task<AsyncLock.Holder> | The acquired lock holder. |
Type Parameters
Name | Description |
---|---|
T | The type of the object to be locked. |