/**
 * @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<unknown> {
    #private;
    constructor(owner: {}, initial?: PromiseLike<unknown>);
    /**
     * Prevent new tasks and wait for remaining tasks to complete.
     */
    close(): Promise<void>;
    /**
     * 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<TResult1 = void, TResult2 = never>(onfulfilled?: ((value: unknown) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): PromiseLike<TResult1 | TResult2>;
    /**
     * 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<unknown> | (() => PromiseLike<unknown>)): void;
    /**
     * Enqueue work with an awaitable result.
     */
    produce<T>(task: () => PromiseLike<T>): Promise<T>;
    /**
     * 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<Disposable>;
    /**
     * Activate a task.
     */
    protected initiateTask(task: PromiseLike<unknown> | (() => PromiseLike<unknown>)): Promise<unknown>;
}
//# sourceMappingURL=Mutex.d.ts.map