source: trip-planner-front/node_modules/jest-worker/build/WorkerPool.js@ 6c1585f

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

initial commit

  • Property mode set to 100644
File size: 1.2 KB
Line 
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 */
20const canUseWorkerThreads = () => {
21 try {
22 require('worker_threads');
23
24 return true;
25 } catch {
26 return false;
27 }
28};
29
30class WorkerPool extends _BaseWorkerPool.default {
31 send(workerId, request, onStart, onEnd, onCustomMessage) {
32 this.getWorkerById(workerId).send(request, onStart, onEnd, onCustomMessage);
33 }
34
35 createWorker(workerOptions) {
36 let Worker;
37
38 if (this._options.enableWorkerThreads && canUseWorkerThreads()) {
39 Worker = require('./workers/NodeThreadsWorker').default;
40 } else {
41 Worker = require('./workers/ChildProcessWorker').default;
42 }
43
44 return new Worker(workerOptions);
45 }
46}
47
48var _default = WorkerPool;
49exports.default = _default;
Note: See TracBrowser for help on using the repository browser.