UNPKG

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