@naturalcycles/nodejs-lib
Version:
Standard library for Node.js
32 lines (31 loc) • 1.01 kB
TypeScript
import { AnyObject } from '@naturalcycles/js-lib';
import { TransformTyped } from '../../stream.model';
export interface TransformMultiThreadedOptions {
/**
* Absolute path to a js file with worker code
*/
workerFile: string;
/**
* @default 2, to match CircleCI and Github Actions environments
*/
poolSize?: number;
/**
* @default to poolSize
*/
concurrency?: number;
/**
* @default to Math.max(16, concurrency x 2)
*/
highWaterMark?: number;
/**
* Passed to the Worker as `workerData` property (initial data).
*/
workerData?: AnyObject;
}
/**
* Spawns a pool of Workers (threads).
* Distributes (using round-robin, equally) all inputs over Workers.
* Workers emit 1 output for each 1 input.
* Output of Workers is passed down the stream. Order is RANDOM (since it's a multi-threaded environment).
*/
export declare function transformMultiThreaded<IN, OUT>(opt: TransformMultiThreadedOptions): TransformTyped<IN, OUT>;