docs: add utility process info to tutorial docs (#36074)
This commit is contained in:
parent
02ad8fcd5f
commit
260678bd0c
1 changed files with 17 additions and 0 deletions
|
@ -214,8 +214,25 @@ This feature is incredibly useful for two main purposes:
|
||||||
URL, you can add custom properties onto the renderer's `window` global that can
|
URL, you can add custom properties onto the renderer's `window` global that can
|
||||||
be used for desktop-only logic on the web client's side.
|
be used for desktop-only logic on the web client's side.
|
||||||
|
|
||||||
|
## The utility process
|
||||||
|
|
||||||
|
Each Electron app can spawn multiple child processes from the main process using
|
||||||
|
the [UtilityProcess][] API. The utility process runs in a Node.js environment,
|
||||||
|
meaning it has the ability to `require` modules and use all of Node.js APIs.
|
||||||
|
The utility process can be used to host for example: untrusted services,
|
||||||
|
CPU intensive tasks or crash prone components which would have previously
|
||||||
|
been hosted in the main process or process spawned with Node.js [`child_process.fork`][] API.
|
||||||
|
The primary difference between the utility process and process spawned by Node.js
|
||||||
|
child_process module is that the utility process can establish a communication
|
||||||
|
channel with a renderer process using [`MessagePort`][]s. An Electron app can
|
||||||
|
always prefer the [UtilityProcess][] API over Node.js [`child_process.fork`][] API when
|
||||||
|
there is need to fork a child process from the main process.
|
||||||
|
|
||||||
[window-mdn]: https://developer.mozilla.org/en-US/docs/Web/API/Window
|
[window-mdn]: https://developer.mozilla.org/en-US/docs/Web/API/Window
|
||||||
|
[`MessagePort`]: https://developer.mozilla.org/en-US/docs/Web/API/MessagePort
|
||||||
|
[`child_process.fork`]: https://nodejs.org/dist/latest-v16.x/docs/api/child_process.html#child_processforkmodulepath-args-options
|
||||||
[context-isolation]: ./context-isolation.md
|
[context-isolation]: ./context-isolation.md
|
||||||
[context-bridge]: ../api/context-bridge.md
|
[context-bridge]: ../api/context-bridge.md
|
||||||
[ipcrenderer]: ../api/ipc-renderer.md
|
[ipcrenderer]: ../api/ipc-renderer.md
|
||||||
|
[UtilityProcess]: ../api/utility-process.md
|
||||||
[tutorial]: ./tutorial-1-prerequisites.md
|
[tutorial]: ./tutorial-1-prerequisites.md
|
||||||
|
|
Loading…
Reference in a new issue