UNPKG

node-worker-threads-pool-ts

Version:

Simple worker threads pool using Node's worker_threads module. Compatible with ES6+ Promise, Typescript, Async/Await.

20 lines (19 loc) 599 B
/// <reference types="node" /> import { TransferList } from "./pool"; export interface TaskConfig { timeout?: number; transferList?: TransferList; } import { Worker, WorkerOptions } from "worker_threads"; import { URL } from "url"; export declare class PoolWorker extends Worker { private isDone?; ready: boolean; constructor(filename: string | URL, options?: WorkerOptions, isDone?: ((message: any) => boolean) | undefined); run(param: any, taskConfig: TaskConfig): Promise<any>; readyToWork(): void; /** * @override */ terminate(): Promise<number>; }