| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 5c71f49 commit c182198
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -457,6 +457,15 @@ of the custom deprecation. | |||
| 457 | 457 | The `*-deprecation` command-line flags only affect warnings that use the name | |
| 458 | 458 | `'DeprecationWarning'`. | |
| 459 | 459 | ||
| 460 | + ### Event: `'worker'` | ||
| 461 | + <!-- YAML | ||
| 462 | + added: REPLACEME | ||
| 463 | + --> | ||
| 464 | + | ||
| 465 | + * `worker` {Worker} The {Worker} that was created. | ||
| 466 | + | ||
| 467 | + The `'worker'` event is emitted after a new {Worker} thread has been created. | ||
| 468 | + | ||
| 460 | 469 | #### Emitting custom warnings | |
| 461 | 470 | ||
| 462 | 471 | See the [`process.emitWarning()`][process_emit_warning] method for issuing | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -266,6 +266,8 @@ class Worker extends EventEmitter { | |||
| 266 | 266 | }; | |
| 267 | 267 | // Actually start the new thread now that everything is in place. | |
| 268 | 268 | this[kHandle].startThread(); | |
| 269 | + | ||
| 270 | + process.nextTick(() => process.emit('worker', this)); | ||
| 269 | 271 | } | |
| 270 | 272 | ||
| 271 | 273 | [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