source: trip-planner-front/node_modules/jest-worker/build/PriorityQueue.d.ts@ 59329aa

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

initial commit

  • Property mode set to 100644
File size: 1.4 KB
Line 
1/**
2 * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7import type { QueueChildMessage, TaskQueue } from './types';
8export declare type ComputeTaskPriorityCallback = (method: string, ...args: Array<unknown>) => number;
9declare type QueueItem = {
10 task: QueueChildMessage;
11 priority: number;
12};
13/**
14 * Priority queue that processes tasks in natural ordering (lower priority first)
15 * accoridng to the priority computed by the function passed in the constructor.
16 *
17 * FIFO ordering isn't guaranteed for tasks with the same priority.
18 *
19 * Worker specific tasks with the same priority as a non-worker specific task
20 * are always processed first.
21 */
22export default class PriorityQueue implements TaskQueue {
23 private _computePriority;
24 private _queue;
25 private _sharedQueue;
26 constructor(_computePriority: ComputeTaskPriorityCallback);
27 enqueue(task: QueueChildMessage, workerId?: number): void;
28 _enqueue(task: QueueChildMessage, queue: MinHeap<QueueItem>): void;
29 dequeue(workerId: number): QueueChildMessage | null;
30 _getWorkerQueue(workerId: number): MinHeap<QueueItem>;
31}
32declare type HeapItem = {
33 priority: number;
34};
35declare class MinHeap<TItem extends HeapItem> {
36 private _heap;
37 peek(): TItem | null;
38 add(item: TItem): void;
39 poll(): TItem | null;
40}
41export {};
Note: See TracBrowser for help on using the repository browser.