parallel-es
Version:
Simple parallelization for EcmaScript
40 lines (39 loc) • 1.58 kB
TypeScript
import { FunctionCallDeserializer } from "../../function/function-call-deserializer";
import { ISerializedFunctionCall } from "../../function/serialized-function-call";
import { ISerializedParallelOperation, IParallelEnvironment } from "../";
/**
* Defines the parallel operation to perform
*/
export interface IParallelJobDefinition {
/**
* The generator that is used to create the array that is "manipulated" by applying the given actions.
*/
generator: ISerializedFunctionCall;
/**
* The operations to perform on the array elements
*/
operations: ISerializedParallelOperation[];
/**
* The environments. Object hash that is passed to all iteratee functions and allows to access external data
*/
environments: Array<ISerializedFunctionCall | IParallelEnvironment>;
/**
* The job-relative index of the task
*/
taskIndex: number;
/**
* The number of values processed by each task (at most)
*/
valuesPerTask: number;
}
/**
* Main coordination function for any operation performed using {@link IParallel}.
* @param definition the definition of the operation to performed
* @param options options passed from the thread pool
* @param T type of the elements created by the generator
* @param TResult type of the resulting elements
* @returns the result of the operation from this worker
*/
export declare function parallelJobExecutor<T, TResult>(definition: IParallelJobDefinition, {functionCallDeserializer}: {
functionCallDeserializer: FunctionCallDeserializer;
}): TResult[];