-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
51 lines (51 loc) · 1.27 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/// <reference types="node" />
export type ThreadPoolArgs = {
/**
* - Function to run in each thread.
*/
task: Function;
/**
* - Number of threads
*/
size?: number;
};
declare const ThreadPool_base: typeof import("events").EventEmitter;
export class ThreadPool extends ThreadPool_base {
/**
* Create a thread pool that runs a specific function
*
* @param {ThreadPoolArgs}
*/
constructor({ task, size }: ThreadPoolArgs);
/**
* Determines if you're currently running in the main or thread context
* @type {boolean}
* */
isMainThread: boolean;
/**
* Create a thread pool that runs a specific function
*
* @param {...any} args - Arguments passed to the configured task.
* @returns {Promise<any>}
*/
run(...args: any[]): Promise<any>;
/**
* Queue several functions
*
* @param {function} fn - Function to queue
* @returns {Promise<any>}
*/
queue(fn: Function): Promise<any>;
/**
* Wait until the queue is empty
* @returns {Promise<any>}
*/
wait(): Promise<any>;
/**
* Wait until the queue is empty, then terminate all listeners
* @returns {Promise<any>}
*/
close(): Promise<any>;
#private;
}
export {};