Class KeyLocker<T>
Provides a mechanism for locking resources based on a key.
Namespace: Singulink.Threading
Assembly: Singulink.Threading.dll
Syntax
public class KeyLocker<T> where T : notnull
Type Parameters
| Name | Description |
|---|---|
| T | The type of the key used to identify locks. |
Constructors
| Name | Description |
|---|---|
| KeyLocker() | Initializes a new instance of the KeyLocker<T> class. |
| KeyLocker(IEqualityComparer<T>?) | Initializes a new instance of the KeyLocker<T> class with a specified equality comparer for the keys. |
Methods
| Name | Description |
|---|---|
| IsLocked(T) | Checks if a lock is currently held for the specified key. |
| Lock(T, int, CancellationToken) | Acquires a lock for the specified key. If the lock is already held, it will wait until it can acquire the lock or the specified timeout expires. |
| Lock(T, CancellationToken) | Acquires a lock for the specified key. If the lock is already held, it will wait until it can acquire the lock. |
| Lock(T, TimeSpan, CancellationToken) | Acquires a lock for the specified key. If the lock is already held, it will wait until it can acquire the lock or the specified timeout expires. |
| LockAsync(T, int, CancellationToken) | Asynchronously acquires a lock for the specified key. If the lock is already held, it will wait until it can acquire the lock or the specified timeout expires. |
| LockAsync(T, CancellationToken) | Asynchronously acquires a lock for the specified key. If the lock is already held, it will wait until it can acquire the lock. |
| LockAsync(T, TimeSpan, CancellationToken) | Asynchronously acquires a lock for the specified key. If the lock is already held, it will wait until it can acquire the lock or the specified timeout expires. |