/**
 * High-Performance Worker Pool Manager
 * Provides thread-safe parallel processing for CPU-intensive data analysis operations
 */
import { EventEmitter } from 'events';
export interface WorkerTask<T = any, R = any> {
    id: string;
    type: string;
    data: T;
    timeout?: number;
    priority?: 'low' | 'normal' | 'high';
}
export interface WorkerResult<R = any> {
    taskId: string;
    success: boolean;
    result?: R;
    error?: string;
    executionTime: number;
    memoryUsage?: number;
}
export interface WorkerStats {
    totalWorkers: number;
    availableWorkers: number;
    busyWorkers: number;
    queuedTasks: number;
    activeTasksCount: number;
    maxWorkers: number;
}
export interface WorkerPoolOptions {
    maxWorkers?: number;
    idleTimeout?: number;
    taskTimeout?: number;
    enableMemoryMonitoring?: boolean;
    memoryLimitMB?: number;
}
/**
 * High-performance worker pool for parallel data processing
 */
export declare class WorkerPool extends EventEmitter {
    private workers;
    private availableWorkers;
    private busyWorkers;
    private taskQueue;
    private activeTasksCount;
    private maxWorkers;
    private idleTimeout;
    private taskTimeout;
    private enableMemoryMonitoring;
    private memoryLimitMB;
    private workerScript;
    constructor(workerScript: string, options?: WorkerPoolOptions);
    /**
     * Execute a task in the worker pool
     */
    execute<T, R>(task: WorkerTask<T, R>): Promise<R>;
    /**
     * Execute multiple tasks in parallel with controlled concurrency
     */
    executeAll<T, R>(tasks: WorkerTask<T, R>[], maxConcurrency?: number): Promise<R[]>;
    /**
     * Add task to priority queue
     */
    private addToQueue;
    /**
     * Process the task queue
     */
    private processQueue;
    /**
     * Execute a task on a specific worker
     */
    private executeTaskOnWorker;
    /**
     * Create a new worker
     */
    private createWorker;
    /**
     * Setup idle timeout for worker cleanup
     */
    private setupWorkerIdleTimeout;
    /**
     * Handle worker timeout
     */
    private handleWorkerTimeout;
    /**
     * Remove a worker from the pool
     */
    private removeWorker;
    /**
     * Get pool statistics
     */
    getStats(): WorkerStats;
    /**
     * Gracefully shutdown the worker pool
     */
    shutdown(): Promise<void>;
    /**
     * Check if we're running in the main thread
     */
    static isMainThread(): boolean;
}
/**
 * Get or create the global worker pool
 */
export declare function getGlobalWorkerPool(workerScript?: string, options?: WorkerPoolOptions): WorkerPool;
/**
 * Shutdown the global worker pool
 */
export declare function shutdownGlobalWorkerPool(): Promise<void>;
//# sourceMappingURL=worker-pool.d.ts.map