| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 93af04a commit 99735a6
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -455,6 +455,15 @@ of the custom deprecation. | |||
| 455 | 455 | The `*-deprecation` command-line flags only affect warnings that use the name | |
| 456 | 456 | `'DeprecationWarning'`. | |
| 457 | 457 | ||
| 458 | + ### Event: `'worker'` | ||
| 459 | + <!-- YAML | ||
| 460 | + added: REPLACEME | ||
| 461 | + --> | ||
| 462 | + | ||
| 463 | + * `worker` {Worker} The {Worker} that was created. | ||
| 464 | + | ||
| 465 | + The `'worker'` event is emitted after a new {Worker} thread has been created. | ||
| 466 | + | ||
| 458 | 467 | #### Emitting custom warnings | |
| 459 | 468 | ||
| 460 | 469 | See the [`process.emitWarning()`][process_emit_warning] method for issuing | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -261,6 +261,8 @@ class Worker extends EventEmitter { | |||
| 261 | 261 | }; | |
| 262 | 262 | // Actually start the new thread now that everything is in place. | |
| 263 | 263 | this[kHandle].startThread(); | |
| 264 | + | ||
| 265 | + process.nextTick(() => process.emit('worker', this)); | ||
| 264 | 266 | } | |
| 265 | 267 | ||
| 266 | 268 | [kOnExit](code, customErr, customErrReason) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,13 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + const common = require('../common'); | ||
| 4 | + const assert = require('assert'); | ||
| 5 | + const { | ||
| 6 | + Worker, | ||
| 7 | + } = require('worker_threads'); | ||
| 8 | + | ||
| 9 | + process.on('worker', common.mustCall(({ threadId }) => { | ||
| 10 | + assert.strictEqual(threadId, 1); | ||
| 11 | + })); | ||
| 12 | + | ||
| 13 | + new Worker('', { eval: true }); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments