import type { OperationExecutionRecord } from './OperationExecutionRecord';
/**
 * Implementation of the async iteration protocol for a collection of IOperation objects.
 * The async iterator will wait for an operation to be ready for execution, or terminate if there are no more operations.
 *
 * @remarks
 * If the caller does not update dependencies prior to invoking `next()` on the iterator again,
 * it must manually invoke `assignOperations()` after performing the updates, otherwise iterators will
 * stall until another operations completes.
 */
export declare class AsyncOperationQueue implements AsyncIterable<OperationExecutionRecord>, AsyncIterator<OperationExecutionRecord> {
    private readonly _queue;
    private readonly _pendingIterators;
    private readonly _totalOperations;
    private readonly _completedOperations;
    /**
     * Tracks how many times each operation has been assigned to an execution slot.
     * Operations that have been assigned more times (e.g. cobuild retries) are sorted
     * after operations with fewer attempts, so untried work is preferred.
     */
    private readonly _numberOfTimesQueuedByOperation;
    private _isDone;
    /**
     * @param operations - The set of operations to be executed
     * @param sortFn - A function that sorts operations in reverse priority order:
     *   - Returning a positive value indicates that `a` should execute before `b`.
     *   - Returning a negative value indicates that `b` should execute before `a`.
     *   - Returning 0 indicates no preference.
     */
    constructor(operations: Iterable<OperationExecutionRecord>, sortFn: IOperationSortFunction);
    /**
     * For use with `for await (const operation of taskQueue)`
     * @see {AsyncIterator}
     */
    next(): Promise<IteratorResult<OperationExecutionRecord>>;
    /**
     * Set a callback to be invoked when one operation is completed.
     * If all operations are completed, set the queue to done, resolve all pending iterators in next cycle.
     */
    complete(record: OperationExecutionRecord): void;
    /**
     * Routes ready operations with 0 dependencies to waiting iterators. Normally invoked as part of `next()`, but
     * if the caller does not update operation dependencies prior to calling `next()`, may need to be invoked manually.
     */
    assignOperations(): void;
    /**
     * Returns this queue as an async iterator, such that multiple functions iterating this object concurrently
     * receive distinct iteration results.
     */
    [Symbol.asyncIterator](): AsyncIterator<OperationExecutionRecord>;
}
export interface IOperationSortFunction {
    /**
     * A function that sorts operations in reverse priority order:
     * Returning a positive value indicates that `a` should execute before `b`.
     * Returning a negative value indicates that `b` should execute before `a`.
     * Returning 0 indicates no preference.
     */
    (a: OperationExecutionRecord, b: OperationExecutionRecord): number;
}
//# sourceMappingURL=AsyncOperationQueue.d.ts.map