source: trip-planner-front/node_modules/piscina/dist/src/index.d.ts@ e29cc2e

Last change on this file since e29cc2e was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 3.6 KB
Line 
1/// <reference types="node" />
2import { Worker, MessagePort } from 'worker_threads';
3import EventEmitterAsyncResource from 'eventemitter-asyncresource';
4import { Transferable, TaskQueue } from './common';
5interface AbortSignalEventTargetAddOptions {
6 once: boolean;
7}
8interface AbortSignalEventTarget {
9 addEventListener: (name: 'abort', listener: () => void, options?: AbortSignalEventTargetAddOptions) => void;
10 removeEventListener: (name: 'abort', listener: () => void) => void;
11 aborted?: boolean;
12}
13interface AbortSignalEventEmitter {
14 off: (name: 'abort', listener: () => void) => void;
15 once: (name: 'abort', listener: () => void) => void;
16}
17declare type AbortSignalAny = AbortSignalEventTarget | AbortSignalEventEmitter;
18declare type ResourceLimits = Worker extends {
19 resourceLimits?: infer T;
20} ? T : {};
21declare type EnvSpecifier = typeof Worker extends {
22 new (filename: never, options?: {
23 env: infer T;
24 }): Worker;
25} ? T : never;
26interface Options {
27 filename?: string | null;
28 name?: string;
29 minThreads?: number;
30 maxThreads?: number;
31 idleTimeout?: number;
32 maxQueue?: number | 'auto';
33 concurrentTasksPerWorker?: number;
34 useAtomics?: boolean;
35 resourceLimits?: ResourceLimits;
36 argv?: string[];
37 execArgv?: string[];
38 env?: EnvSpecifier;
39 workerData?: any;
40 taskQueue?: TaskQueue;
41 niceIncrement?: number;
42 trackUnmanagedFds?: boolean;
43}
44interface FilledOptions extends Options {
45 filename: string | null;
46 name: string;
47 minThreads: number;
48 maxThreads: number;
49 idleTimeout: number;
50 maxQueue: number;
51 concurrentTasksPerWorker: number;
52 useAtomics: boolean;
53 taskQueue: TaskQueue;
54 niceIncrement: number;
55}
56interface RunOptions {
57 transferList?: TransferList;
58 filename?: string | null;
59 signal?: AbortSignalAny | null;
60 name?: string | null;
61}
62declare type TransferList = MessagePort extends {
63 postMessage(value: any, transferList: infer T): any;
64} ? T : never;
65declare type TransferListItem = TransferList extends (infer T)[] ? T : never;
66declare class Piscina extends EventEmitterAsyncResource {
67 #private;
68 constructor(options?: Options);
69 /** @deprecated Use run(task, options) instead **/
70 runTask(task: any, transferList?: TransferList, filename?: string, abortSignal?: AbortSignalAny): Promise<any>;
71 /** @deprecated Use run(task, options) instead **/
72 runTask(task: any, transferList?: TransferList, filename?: AbortSignalAny, abortSignal?: undefined): Promise<any>;
73 /** @deprecated Use run(task, options) instead **/
74 runTask(task: any, transferList?: string, filename?: AbortSignalAny, abortSignal?: undefined): Promise<any>;
75 /** @deprecated Use run(task, options) instead **/
76 runTask(task: any, transferList?: AbortSignalAny, filename?: undefined, abortSignal?: undefined): Promise<any>;
77 run(task: any, options?: RunOptions): Promise<any>;
78 destroy(): Promise<void>;
79 get options(): FilledOptions;
80 get threads(): Worker[];
81 get queueSize(): number;
82 get completed(): number;
83 get waitTime(): any;
84 get runTime(): any;
85 get utilization(): number;
86 get duration(): number;
87 static get isWorkerThread(): boolean;
88 static get workerData(): any;
89 static get version(): string;
90 static get Piscina(): typeof Piscina;
91 static move(val: Transferable | TransferListItem | ArrayBufferView | ArrayBuffer | MessagePort): ArrayBuffer | ArrayBufferView | MessagePort | Transferable;
92 static get transferableSymbol(): symbol;
93 static get valueSymbol(): symbol;
94 static get queueOptionsSymbol(): symbol;
95}
96export = Piscina;
Note: See TracBrowser for help on using the repository browser.