/** * @nahisaho/yata-scale - Worker Pool * * Manages worker threads for parallel query execution */ /** * Task to execute */ export interface WorkerTask { readonly id: string; readonly data: T; readonly execute: (data: T) => Promise; } /** * Task result */ export interface TaskResult { readonly taskId: string; readonly result?: R; readonly error?: Error; readonly durationMs: number; } /** * Worker pool statistics */ export interface WorkerPoolStats { readonly poolSize: number; readonly activeTasks: number; readonly queuedTasks: number; readonly completedTasks: number; readonly failedTasks: number; readonly avgDurationMs: number; } /** * Worker pool for parallel task execution * Note: In Node.js, this would use worker_threads * This is a simplified async implementation */ export declare class WorkerPool { private readonly poolSize; private activeTasks; private queuedTasks; private completedTasks; private failedTasks; private totalDuration; constructor(poolSize?: number); /** * Submit a task for execution */ submit(task: WorkerTask): Promise>; /** * Execute a task */ private executeTask; /** * Process queued tasks */ private processQueue; /** * Submit multiple tasks and wait for all */ submitAll(tasks: WorkerTask[]): Promise[]>; /** * Submit multiple tasks and get first result */ submitRace(tasks: WorkerTask[]): Promise>; /** * Map operation over data with parallelism */ map(items: T[], fn: (item: T) => Promise, taskIdPrefix?: string): Promise; /** * Filter operation with parallelism */ filter(items: T[], predicate: (item: T) => Promise, taskIdPrefix?: string): Promise; /** * Reduce operation (sequential with parallel mapping) */ reduce(items: T[], fn: (acc: R, item: T) => Promise, initial: R): Promise; /** * Get pool statistics */ getStats(): WorkerPoolStats; /** * Wait for all active tasks to complete */ drain(): Promise; /** * Clear queued tasks */ clear(): void; /** * Shutdown the pool */ shutdown(): Promise; /** * Get active task count */ get activeCount(): number; /** * Get queued task count */ get queuedCount(): number; /** * Check if pool is idle */ get isIdle(): boolean; } //# sourceMappingURL=WorkerPool.d.ts.map