menu
AsyncMutex
import { AsyncMutex } from "destack:async";
Asynchronous mutual exclusion lock.
1export class AsyncMutex<T> {2 value: T;3 constructor(value: T);4 lock(): Task<AsyncMutexGuard<T>>;5 tryLock(): AsyncMutexGuard<T> | undefined;6 getExclusive(): &exclusive T;7 intoInner(): T;8}Members
value: TThe protected value.
constructor(value: T)Create an async mutex protecting
value.lock(): Task<AsyncMutexGuard<T>>Lock this mutex by suspending the current task.
tryLock(): AsyncMutexGuard<T> | undefinedTry to lock this mutex without suspending.
getExclusive(): &exclusive TBorrow the protected value without locking.
intoInner(): TConsume this mutex and return the protected value.