menu

AsyncRwLock

import { AsyncRwLock } from "destack:async";

Asynchronous reader-writer lock.

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

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

Try to lock this value for shared reading.

write(): Task<AsyncRwLockWriteGuard<T>>

Lock this value for exclusive writing.

tryWrite(): AsyncRwLockWriteGuard<T> | undefined

Try to lock this value for exclusive writing.

getExclusive(): &exclusive T

Borrow the protected value without locking.

intoInner(): T

Consume this lock and return the protected value.