UNPKG

1.32 kBTypeScriptView Raw
1export declare class PrioritizedTaskExecutor {
2 /** The maximum size of the pool */
3 private maxPoolSize;
4 /** The current size of the pool */
5 private currentPoolSize;
6 /** The task queue */
7 private queue;
8 /**
9 * Executes tasks up to maxPoolSize at a time, other items are put in a priority queue.
10 * @class PrioritizedTaskExecutor
11 * @private
12 * @param maxPoolSize The maximum size of the pool
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}