Farm.d.ts 1.0 KB

1234567891011121314151617181920212223242526272829
  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 { FarmOptions, PromiseWithCustomMessage, TaskQueue } from './types';
  8. export default class Farm {
  9. private _numOfWorkers;
  10. private _callback;
  11. private readonly _computeWorkerKey;
  12. private readonly _workerSchedulingPolicy;
  13. private readonly _cacheKeys;
  14. private readonly _locks;
  15. private _offset;
  16. private readonly _taskQueue;
  17. constructor(_numOfWorkers: number, _callback: Function, options?: {
  18. computeWorkerKey?: FarmOptions['computeWorkerKey'];
  19. workerSchedulingPolicy?: FarmOptions['workerSchedulingPolicy'];
  20. taskQueue?: TaskQueue;
  21. });
  22. doWork(method: string, ...args: Array<unknown>): PromiseWithCustomMessage<unknown>;
  23. private _process;
  24. private _push;
  25. private _getNextWorkerOffset;
  26. private _lock;
  27. private _unlock;
  28. private _isLocked;
  29. }