diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2018-06-17 19:40:58 +0300 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2018-07-18 13:59:32 +0300 |
commit | 581390c59d2a003bc7fcc7d3727dce2dafde21fd (patch) | |
tree | ac64c6dfeefc6ee4120bc3ddfe818af430f11f14 /node.gyp | |
parent | eef975ebae7a166b41f8dd2e65aec9aa0b5a5fc4 (diff) |
process: split bootstrappers by threads that can run them
This patch split part of the bootstrappers into three files:
- `lib/internal/process/main_thread_only.js`: contains bootstrappers
that can only be run in the main thread, including
- `setupStdio` for the main thread that sets up `process.stdin`,
`process.stdout`, `process.error` that may interact with external
resources, e.g. TTY/File/Pipe/TCP sockets
- `setupProcessMethods` that setup methods changing process-global
states, e.g. `process.chdir`, `process.umask`, `process.setuid`
- `setupSignalHandlers`
- `setupChildProcessIpcChannel` that setup `process.send` for
child processes.
- `lib/internal/process/worker_thread_only.js`: contains bootstrappers
that can only be run in the worker threads, including
- `setupStdio` for the worker thread that are streams to be
manipulated or piped to the parent thread
- `lib/internal/process/per_thread.js`: contains bootstrappers
that can be run in all threads, including:
- `setupAssert` for `process.assert`
- `setupCpuUsage` for `process.cpuUsage`
- `setupHrtime` for `process.hrtime` and `process.hrtime.bigint`
- `setupMemoryUsage` for `process.memoryUsage`
- `setupConfig` for `process.config`
- `setupKillAndExit` for `process.kill` and `process.exit`
- `setupRawDebug` for `process._rawDebug`
- `setupUncaughtExceptionCapture` for
`process.setUncaughtExceptionCaptureCallback` and
`process.hasUncaughtExceptionCaptureCallback`
Hopefully in the future we can sort more bootstrappers in
`boostrap/node.js` into these three files and further group
them into functions that can be run before creating the
snapshot / after loading the snapshot.
This patch also moves most of the `isMainThread` conditionals
into the main bootstrapper instead of letting them scattered around
special-casing different implementations.
PR-URL: https://github.com/nodejs/node/pull/21378
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Backport-PR-URL: https://github.com/nodejs/node/pull/21866
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Diffstat (limited to 'node.gyp')
-rw-r--r-- | node.gyp | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -133,12 +133,13 @@ 'lib/internal/net.js', 'lib/internal/os.js', 'lib/internal/process/esm_loader.js', - 'lib/internal/process/methods.js', + 'lib/internal/process/main_thread_only.js', 'lib/internal/process/next_tick.js', + 'lib/internal/process/per_thread.js', 'lib/internal/process/promises.js', 'lib/internal/process/stdio.js', 'lib/internal/process/warning.js', - 'lib/internal/process.js', + 'lib/internal/process/worker_thread_only.js', 'lib/internal/querystring.js', 'lib/internal/process/write-coverage.js', 'lib/internal/readline.js', |