()
| 538 | } |
| 539 | |
| 540 | waitForWorker() { |
| 541 | if (!this.#isReady) { |
| 542 | const { kIsOnline } = require('internal/worker'); |
| 543 | if (!this.#worker[kIsOnline]) { |
| 544 | debug('wait for signal from worker'); |
| 545 | AtomicsWait(this.#lock, WORKER_TO_MAIN_THREAD_NOTIFICATION, 0); |
| 546 | const response = this.#worker.receiveMessageSync(); |
| 547 | if (response == null) { return; } |
| 548 | if (response.message.status === 'exit') { |
| 549 | process.exit(response.message.body); |
| 550 | } |
| 551 | |
| 552 | // ! This line catches initialization errors in the worker thread. |
| 553 | this.#unwrapMessage(response); |
| 554 | } |
| 555 | |
| 556 | this.#isReady = true; |
| 557 | } |
| 558 | } |
| 559 | |
| 560 | /** |
| 561 | * Invoke a remote method asynchronously. |
no test coverage detected