menu
AsyncRwLock
import { AsyncRwLock } from "destack:async";
Asynchronous reader-writer lock.
1export class AsyncRwLock<T> {2 value: T;3 constructor(value: T);4 read(): Task<AsyncRwLockReadGuard<T>>;5 tryRead(): AsyncRwLockReadGuard<T> | undefined;6 write(): Task<AsyncRwLockWriteGuard<T>>;7 tryWrite(): AsyncRwLockWriteGuard<T> | undefined;8 getExclusive(): &exclusive T;9 intoInner(): T;10}Members
value: TThe protected value.
constructor(value: T)Create an async reader-writer lock protecting
value.read(): Task<AsyncRwLockReadGuard<T>>Lock this value for shared reading.
tryRead(): AsyncRwLockReadGuard<T> | undefinedTry to lock this value for shared reading.
write(): Task<AsyncRwLockWriteGuard<T>>Lock this value for exclusive writing.
tryWrite(): AsyncRwLockWriteGuard<T> | undefinedTry to lock this value for exclusive writing.
getExclusive(): &exclusive TBorrow the protected value without locking.
intoInner(): TConsume this lock and return the protected value.