mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
worker: add name for worker
PR-URL: https://github.com/nodejs/node/pull/59213 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
a4ce69e05f
commit
3090def635
11 changed files with 118 additions and 5 deletions
18
test/parallel/test-worker-thread-name.js
Normal file
18
test/parallel/test-worker-thread-name.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
'use strict';
|
||||
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
const { Worker, threadName, workerData } = require('worker_threads');
|
||||
|
||||
const name = 'test-worker-thread-name';
|
||||
|
||||
if (workerData?.isWorker) {
|
||||
assert.strictEqual(threadName, name);
|
||||
process.exit(0);
|
||||
} else {
|
||||
const w = new Worker(__filename, { name, workerData: { isWorker: true } });
|
||||
assert.strictEqual(w.threadName, name);
|
||||
w.on('exit', common.mustCall(() => {
|
||||
assert.strictEqual(w.threadName, null);
|
||||
}));
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue