WorkerPool.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _BaseWorkerPool = _interopRequireDefault(require('./base/BaseWorkerPool'));
  7. function _interopRequireDefault(obj) {
  8. return obj && obj.__esModule ? obj : {default: obj};
  9. }
  10. /**
  11. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  12. *
  13. * This source code is licensed under the MIT license found in the
  14. * LICENSE file in the root directory of this source tree.
  15. */
  16. class WorkerPool extends _BaseWorkerPool.default {
  17. send(workerId, request, onStart, onEnd, onCustomMessage) {
  18. this.getWorkerById(workerId).send(request, onStart, onEnd, onCustomMessage);
  19. }
  20. createWorker(workerOptions) {
  21. let Worker;
  22. if (this._options.enableWorkerThreads) {
  23. Worker = require('./workers/NodeThreadsWorker').default;
  24. } else {
  25. Worker = require('./workers/ChildProcessWorker').default;
  26. }
  27. return new Worker(workerOptions);
  28. }
  29. }
  30. var _default = WorkerPool;
  31. exports.default = _default;