/** * @license * Copyright 2022-2026 Matter.js Authors * SPDX-License-Identifier: Apache-2.0 */ import { Duration } from "#time/Duration.js"; import { Abort } from "./Abort.js"; /** * A work slot that must be released when work is complete. */ export interface WorkSlot extends Disposable { /** * Release the slot manually. * This is called automatically when using `using` syntax. */ close(): void; } /** * A queue that limits concurrent work using a slot-based approach. * * Instead of queueing promises or iterators directly, callers get a "work slot" * which they hold while doing work. The slot must be released when work is complete. */ export declare class Semaphore { #private; constructor(scope: string, concurrency?: number, delay?: Duration); /** * Get a work slot from the queue. * * This method returns a promise that resolves when a slot is available. * The returned slot must be released when work is complete, either by * calling `close()` or by using the `using` syntax. * * @param abort - Optional abort signal to cancel waiting for a slot * @returns A disposable work slot * @throws AbortedError if the abort signal is triggered before a slot is obtained */ obtainSlot(abort?: Abort.Signal): Promise; /** * Clear the queue (entries will be rejected via abort). */ clear(): void; /** * Get the number of pending slot requests in the queue. */ get count(): number; /** * Get the number of currently active slots. */ get running(): number; /** * Close the queue and reject all pending slot requests. */ close(): void; } //# sourceMappingURL=Semaphore.d.ts.map