import { WorkerPool } from './WorkerPool.js'; export declare const toTaskOutputStubs: (res: any) => any; export declare const parseTaskInputStubs: (...rawArgs: any) => any; export declare enum ProcessingState { None = "none", Scheduled = "scheduled", Waiting = "waiting", Pending = "pending", Suspended = "suspended", Canceled = "canceled", Done = "done" } export type TaskHandlerId = string; export type TaskId = string | number; export type GenericTask = ProcessingTask; export type ProcessingTaskStub = { taskId: TaskId; processingInput: ProcessingInput; processingParams: ProcessingParams; handlerId: TaskHandlerId; }; export type GenericTaskStub = ProcessingTaskStub; /** * Handling side */ export type ProcessingTaskHandler = (taskStub: ProcessingTaskStub) => ProcessingOutput; export type AsyncProcessingTaskHandler = (taskStub: ProcessingTaskStub) => ProcessingOutput | Promise; export type GenericTaskHandler = ProcessingTaskHandler; export type BaseProcessingParams = { isDelegated?: boolean; }; /** * Client side */ /** * Tasks can be processed locally on main thread, worker thread * or even remotely on server */ export declare class ProcessingTask { static globalTasksCount: number; processingInput: ProcessingInput; processingParams: ProcessingParams; handlerId: TaskHandlerId; processingState: ProcessingState; taskId: TaskId; rank: number; promise: Promise; resolve: any; reject: any; scheduled: boolean; constructor(handlerId: TaskHandlerId, taskId?: TaskId); get awaitingProcessing(): boolean; getPromise(): Promise; process(taskHandlers: Record>): any; asyncProcess(asyncTaskHandler: Record>): Promise; /** * This will delegate task processing to specific processing environment * like (workerpool, remote, ..): * @param targetEnv target processing environment * @returns */ delegate: (targetEnv: WorkerPool) => Promise; /** * defer task processing * @param delay * @param onDeferredStart * @returns */ defer(workerPool: WorkerPool, delay?: number): Promise | null; /** * run task remotely on server */ request(): void; cancel(): void; suspend(): void; isNotEnqueued: () => boolean; isWaiting: () => boolean; isPending: () => boolean; isInactive(): boolean; /** * will be called on receiver side before processing * to parse input data */ /** * will be called on sender side after processing * to parse output data */ postProcess(rawOutputData: any): any; onStarted: () => void; /** * additional callback where post process actions can be performed * upon task data reception * @param rawData * @returns */ onCompleted(taskOutput: ProcessingOutput): any; onRejected: (error: string) => null; toStub(): ProcessingTaskStub; }