1 | export declare class PrioritizedTaskExecutor {
|
2 |
|
3 | private maxPoolSize;
|
4 |
|
5 | private currentPoolSize;
|
6 |
|
7 | private queue;
|
8 | |
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | constructor(maxPoolSize: number);
|
15 | /**
|
16 | * Executes the task or queues it if no spots are available.
|
17 | * When a task is added, check if there are spots left in the pool.
|
18 | * If a spot is available, claim that spot and give back the spot once the asynchronous task has been resolved.
|
19 | * When no spots are available, add the task to the task queue. The task will be executed at some point when another task has been resolved.
|
20 | * @private
|
21 | * @param priority The priority of the task
|
22 | * @param fn The function that accepts the callback, which must be called upon the task completion.
|
23 | */
|
24 | executeOrQueue(priority: number, fn: Function): void;
|
25 | /**
|
26 | * Checks if the taskExecutor is finished.
|
27 | * @private
|
28 | * @returns Returns `true` if the taskExecutor is finished, otherwise returns `false`.
|
29 | */
|
30 | finished(): boolean;
|
31 | }
|