mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
c2aedd0310
PR-URL: https://github.com/nodejs/node/pull/32509 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
20 lines
474 B
JavaScript
20 lines
474 B
JavaScript
'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);
|
|
});
|
|
});
|
|
}
|