Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PriorityQueue.d.ts 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. */
  7. import type { QueueChildMessage, TaskQueue } from './types';
  8. export declare type ComputeTaskPriorityCallback = (method: string, ...args: Array<unknown>) => number;
  9. declare 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. */
  22. export 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. }
  32. declare type HeapItem = {
  33. priority: number;
  34. };
  35. declare class MinHeap<TItem extends HeapItem> {
  36. private _heap;
  37. peek(): TItem | null;
  38. add(item: TItem): void;
  39. poll(): TItem | null;
  40. }
  41. export {};