Skip to content

Commit

Permalink
process,worker: ensure code after exit() effectless
Browse files Browse the repository at this point in the history
check the worker exits properly in main thread's
beforeExit hook. fix lint and typo.
  • Loading branch information
ywave620 committed Dec 3, 2022
1 parent 0f66f9e commit ad562e1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { Worker, isMainThread } = require('worker_threads');

if (isMainThread) {
const workerData = new Int32Array(new SharedArrayBuffer(4));
const w = new Worker(__filename, {
new Worker(__filename, {
workerData,
});
process.on('beforeExit', common.mustCall(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ const { Worker, isMainThread } = require('worker_threads');

if (isMainThread) {
const workerData = new Int32Array(new SharedArrayBuffer(4));
const w = new Worker(__filename, {
new Worker(__filename, {
workerData,
});
w.on('beforeExit', common.mustCall(() => {
process.on('beforeExit', common.mustCall(() => {
assert.strictEqual(workerData[0], 0);
}));
} else {
Expand Down

0 comments on commit ad562e1

Please sign in to comment.