Welcome to mirror list, hosted at ThFree Co, Russian Federation.

test-worker.js « parallel « test - github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9154aaa12baee1ae3ad107290c6efbcb9b24fc80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
'use strict';
const common = require('../common');
const assert = require('assert');
const { Worker, isMainThread, parentPort } = require('worker_threads');

const kTestString = 'Hello, world!';

if (isMainThread) {
  const w = new Worker(__filename);
  w.on('message', common.mustCall((message) => {
    assert.strictEqual(message, kTestString);
  }));
} else {
  setImmediate(() => {
    process.nextTick(() => {
      parentPort.postMessage(kTestString);
    });
  });
}