Appearance
AsyncReaderWriterLock Class
Definition
Provides an async-compatible, reentrant-aware reader/writer lock with writer preference.
- Namespace:
JASE - Assembly:
JASE.Concurrency.dll
Constructors
| Name | Description |
|---|---|
AsyncReaderWriterLock() | Initializes a new instance of the AsyncReaderWriterLock class. |
Methods
Remarks
Use for shared data that is read often and written occasionally from async code paths. Prefer short critical sections; do not hold a read lock across unrelated await work (I/O, HTTP, long delays).
Multiple readers may hold the lock concurrently.Only one writer may hold the lock at a time.Once a writer is waiting, new readers are blocked until writers are drained.Reentrancy is tracked per logical async flow using AsyncLocal1`.Upgrading from a reader lock to a writer lock in the same flow is not supported. Cancellation or timeout while waiting does not acquire the lock; the lock remains usable for other waiters.