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.

WorkerPool.js 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. const canUseWorkerThreads = () => {
  17. try {
  18. require('worker_threads');
  19. return true;
  20. } catch {
  21. return false;
  22. }
  23. };
  24. class WorkerPool extends _BaseWorkerPool.default {
  25. send(workerId, request, onStart, onEnd, onCustomMessage) {
  26. this.getWorkerById(workerId).send(request, onStart, onEnd, onCustomMessage);
  27. }
  28. createWorker(workerOptions) {
  29. let Worker;
  30. if (this._options.enableWorkerThreads && canUseWorkerThreads()) {
  31. Worker = require('./workers/NodeThreadsWorker').default;
  32. } else {
  33. Worker = require('./workers/ChildProcessWorker').default;
  34. }
  35. return new Worker(workerOptions);
  36. }
  37. }
  38. var _default = WorkerPool;
  39. exports.default = _default;