UNPKG

code-graph-generator

Version:

Generate Json Object of code that can be used to generate code-graphs for JavaScript/TypeScript/Range projects

54 lines (53 loc) 1.57 kB
/** * Task queue for controlled concurrency with error handling and timeout protection */ export declare class TaskQueue { private concurrency; private running; private taskQueue; private completionPromises; private errors; private isShutdown; private taskTimeout; /** * Creates a new TaskQueue * @param concurrency Maximum number of concurrent tasks * @param options Additional options for the queue */ constructor(concurrency: number, options?: { maxQueueSize?: number; taskTimeout?: number; }); /** * Add a task to the queue and get a promise that resolves when it completes * @param task Function to execute * @param priority If true, add to front of queue instead of back * @returns Promise that resolves when the task completes */ push(task: () => Promise<void>, priority?: boolean): Promise<void>; /** * Run the next task if there's capacity */ private runNext; /** * Check if all tasks are complete and resolve/reject completion promises */ private checkCompletion; /** * Wait for all current tasks to complete * @returns Promise that resolves when all tasks are done, or rejects if any fail */ waitForAll(): Promise<void>; /** * Get the number of running tasks */ getRunningCount(): number; /** * Get the number of pending tasks */ getPendingCount(): number; /** * Shut down the queue, rejecting any pending tasks */ shutdown(): void; }