menu

AsyncMutex

import { AsyncMutex } from "destack:async";

Asynchronous mutual exclusion lock.

language/library/src/async/mutex.ds:8:36
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: T

The 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> | undefined

Try to lock this mutex without suspending.

getExclusive(): &exclusive T

Borrow the protected value without locking.

intoInner(): T

Consume this mutex and return the protected value.