/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
import { AsyncResource } from 'async_hooks';
import { EventEmitter } from 'events';
import { Worker, type WorkerOptions } from 'worker_threads';
import { PerformanceMonitor } from './PerformanceMonitor';
declare const kTaskInfo: unique symbol;
declare module 'worker_threads' {
    interface Worker {
        [kTaskInfo]?: WorkerPoolTaskInfo;
    }
}
export declare class WorkerPoolTaskInfo extends AsyncResource {
    protected callback: any;
    protected timeoutIdentifier?: NodeJS.Timeout;
    constructor(callback: any, timeoutIdentifier?: NodeJS.Timeout);
    done(err: any, result: any): void;
    cleanUp(): void;
}
interface WorkerConfig {
    file: string | URL;
    options?: WorkerOptions;
}
interface WorkerPoolConfig {
    workerLimits: {
        minWorkers: number;
        maxWorkers: number;
    };
    shouldCacheResponses?: boolean;
    worker: WorkerConfig;
}
interface WorkerInfo {
    'desired-worker-total': number;
    'workers-total': number;
    'free-workers': number;
}
export declare class WorkerPool<T> extends EventEmitter {
    private poolConfig;
    private workerConfig;
    protected desiredWorkerCount: number;
    protected workers: Worker[];
    protected freeWorkers: Worker[];
    performanceMonitor: PerformanceMonitor;
    private timers;
    static start<U>({ worker: workerConfig, ...poolConfig }: WorkerPoolConfig): WorkerPool<U>;
    constructor(poolConfig: Omit<WorkerPoolConfig, 'worker'>, workerConfig: WorkerPoolConfig['worker']);
    workerInfo(): WorkerInfo;
    addNewWorker(): void;
    protected terminateWorker(worker: Worker, spawnAnother: boolean): Promise<number>;
    runTaskP(task: T, timeoutMs?: number): Promise<unknown>;
    runTask(task: T, callback: any, timeoutMs: number | undefined): void;
    close(): Promise<any[]>;
    get canRunTask(): boolean;
    private get numCurrentTasks();
}
export {};
