/** * @license * Copyright 2022-2026 Matter.js Authors * SPDX-License-Identifier: Apache-2.0 */ import { MatterError } from "#MatterError.js"; export declare class MutexClosedError extends MatterError { constructor(); } /** * A mutex is a task queue where at most one task is active at a time. */ export declare class Mutex implements PromiseLike { #private; constructor(owner: {}, initial?: PromiseLike); /** * Prevent new tasks and wait for remaining tasks to complete. */ close(): Promise; /** * As a PromiseLike, you can await the Mutex. This promise resolves when current activity completes but the mutex * may engage in another activity immediately thereafter. So the mutex is not guaranteed to be available after an * await. */ then(onfulfilled?: ((value: unknown) => TResult1 | PromiseLike) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null): PromiseLike; /** * Enqueue additional work. * * If {@link task} is a function it runs when current activity completes. If it is a promise then the mutex will * not clear until {@link task} resolves. */ run(task: PromiseLike | (() => PromiseLike)): void; /** * Enqueue work with an awaitable result. */ produce(task: () => PromiseLike): Promise; /** * Acquire the lock. * * This offers more natural mutex handling via a disposable. The returned object must be disposed to unlock the * mutex. * * Note that acquiring the lock is async but releasing is not, so you must use `using _lock = await mutex.lock()` * rather than `await using _lock = mutex.lock()`. * * TODO - add abort support */ lock(): Promise; /** * Activate a task. */ protected initiateTask(task: PromiseLike | (() => PromiseLike)): Promise; } //# sourceMappingURL=Mutex.d.ts.map