AsyncMutex Class
Package: @esfx/async-mutex
An async coordination primitive used to coordinate access to a protected resource.
Declaration
export declare class AsyncMutex implements AsyncLockable
Properties
[Symbol.toStringTag]
Declaration
[Symbol.toStringTag]: string;
Property Value
isLocked
Indicates whether the lock has been taken.
Declaration
get isLocked(): boolean;
Property Value
Methods
[AsyncLockable.lock](cancelable)
Declaration
[AsyncLockable.lock](cancelable?: Cancelable): Promise<LockHandle<AsyncMutex>>;
Parameters
- cancelable
- Cancelable
Returns
[AsyncLockable.unlock]()
Declaration
[AsyncLockable.unlock](): void;
Returns
void
lock(cancelable)
Asynchronously waits for the lock to become available and then takes the lock.
Declaration
lock(cancelable?: Cancelable): Promise<LockHandle<AsyncMutex>>;
Parameters
Returns
tryLock()
Synchronously tries to take a lock.
Declaration
tryLock(): boolean;
Returns
unlock()
Releases the lock.
Declaration
unlock(): boolean;