import { BatchClusterEmitter } from "./BatchClusterEmitter"; import { BatchProcess } from "./BatchProcess"; import { Logger } from "./Logger"; import { Task } from "./Task"; /** * Manages task queuing, scheduling, and assignment to ready processes. * Handles the task lifecycle from enqueue to assignment. */ export declare class TaskQueueManager { #private; private readonly emitter?; constructor(logger: () => Logger, emitter?: BatchClusterEmitter | undefined); /** * Add a task to the queue for processing */ enqueue(task: Task): void; /** * Get the number of pending tasks in the queue */ get pendingTaskCount(): number; /** * Get all pending tasks (mostly for testing) */ get pendingTasks(): readonly Task[]; /** * Check if the queue is empty */ get isEmpty(): boolean; /** * Attempt to assign the next task to a ready process. * Returns true if a task was successfully assigned. */ tryAssignNextTask(readyProcess: BatchProcess | undefined): boolean; /** * Remove `task` if it is still waiting for a process. * @return true if the task was removed */ remove(task: Task): boolean; /** * Reject and discard every queued task. * * A queued task has no owning child process, so nothing else will ever * settle it: `ProcessTerminator` only rejects the task a process was * actually running. Leaving them unsettled is the worst outcome for the * caller -- their `await` never returns, and because this library holds no * ref'd handles of its own, node can exit 0 with no error at all. * * @param reason prefixed to each task's command in the rejection message. */ rejectPendingTasks(reason: string): void; /** * Get statistics about task assignment and queue state */ getQueueStats(): { pendingTaskCount: number; isEmpty: boolean; }; }