Class AsyncKeyLock<TKey>
Extension of the AsyncLock that enables fine-grained locking on a given key. Concurrent lock requests using different keys can execute simultaneously, while requests to lock using the same key will be forced to wait. This object is thread-safe and internally uses a pooling mechanism to minimize allocation of new locks.
Implements
Inherited Members
Namespace: SixLabors.ImageSharp.Web.Synchronization
Assembly: SixLabors.ImageSharp.Web.dll
Syntax
public sealed class AsyncKeyLock<TKey> : IDisposable where TKey : notnullType Parameters
| Name | Description | 
|---|---|
| TKey | The type of the key. | 
Constructors
| Edit this page View SourceAsyncKeyLock(int)
Initializes a new instance of the AsyncKeyLock<TKey> class.
Declaration
public AsyncKeyLock(int maxPoolSize = 64)Parameters
| Type | Name | Description | 
|---|---|---|
| int | maxPoolSize | The maximum number of locks that should be pooled for reuse. | 
Methods
| Edit this page View SourceDispose()
Releases all resources used by the current instance of the AsyncKeyLock<TKey> class.
Declaration
public void Dispose()LockAsync(TKey)
Locks the current thread asynchronously.
Declaration
public Task<IDisposable> LockAsync(TKey key)Parameters
| Type | Name | Description | 
|---|---|---|
| TKey | key | The key identifying the specific object to lock against. | 
Returns
| Type | Description | 
|---|---|
| Task<IDisposable> | The IDisposable that will release the lock. |