import { Worker } from 'cluster';
import { HttpProject } from '../../models/HttpProject.js';
import { IProjectExecutionLog } from '../../models/ProjectExecution.js';
import { BaseRunner } from './BaseRunner.js';
import { State } from './enums.js';
import { IProjectParallelRunnerOptions } from './InteropInterfaces.js';
export type WorkerStatus = 'initializing' | 'ready' | 'running' | 'finished' | 'error';
export interface IWorkerInfo {
    /**
     * Whether the worker is online.
     */
    online: boolean;
    /**
     * The number of iterations the worker is performing.
     */
    iterations: number;
    /**
     * The current status of the worker.
     */
    status: WorkerStatus;
    /**
     * Optional error message received from the worker.
     */
    message?: string;
}
interface WorkerInfoInternal extends IWorkerInfo {
    worker?: Worker;
}
export interface IWorkerMessage {
    cmd: string;
    data?: unknown;
}
export interface ProjectParallelRunner {
    /**
     * Dispatched when a status of a worker change.
     * This can be used to render the current status.
     */
    on(event: 'status', listener: (info: IWorkerInfo[]) => void): this;
    /**
     * Dispatched when a status of a worker change.
     * This can be used to render the current status.
     */
    once(event: 'status', listener: (info: IWorkerInfo[]) => void): this;
}
/**
 * Runs a project in parallel.
 * It creates a number of workers determined by the number of CPUs available on the current machine
 * and the number of iterations defined in the configuration options.
 *
 * When the number of iterations is greater then the number of CPUs then
 * the program distributes the remaining iterations among created workers.
 *
 * The program dispatched the `status` event. It is dispatched each time when the worker status
 * change. This event can be user to refresh the UI to reflect the newest state.
 */
export declare class ProjectParallelRunner extends BaseRunner {
    project: HttpProject;
    options: IProjectParallelRunnerOptions;
    workers: WorkerInfoInternal[];
    private mainResolver?;
    private mainRejecter?;
    constructor(project: HttpProject, opts?: IProjectParallelRunnerOptions);
    execute(): Promise<IProjectExecutionLog>;
    protected _state: State;
    get state(): State;
    protected _signal?: AbortSignal;
    /**
     * The abort signal to set on this request.
     * Aborts the request when the signal fires.
     * @type {(AbortSignal | undefined)}
     */
    get signal(): AbortSignal | undefined;
    set signal(value: AbortSignal | undefined);
    /**
     * Aborts the current run.
     * The promise returned by the `execute()` method will reject if not yet resolved.
     */
    abort(): void;
    /**
     * Handler for the `abort` event on the `AbortSignal`.
     */
    protected _abortHandler(): void;
    private _execute;
    private getStatusWorkers;
    private distributeIterations;
    private setupWorker;
    private _messageHandler;
    private _exitHandler;
    private setOnline;
    private setRunResult;
    private runWhenReady;
    private finishWhenReady;
    private setRunError;
}
export {};
//# sourceMappingURL=ProjectParallelRunner.d.ts.map