|
@@ -5,7 +5,7 @@ threads.
|
|
|
|
|
|
## Multi-threaded Node.js
|
|
|
|
|
|
-In Electron, it is supported to use Node.js integration in Web Workers. To do
|
|
|
+It is possible to use Node.js features in Electron's Web Workers, to do
|
|
|
so the `nodeIntegrationInWorker` option should be set to `true` in
|
|
|
`webPreferences`.
|
|
|
|
|
@@ -23,19 +23,19 @@ The `nodeIntegrationInWorker` can be used independent of `nodeIntegration`, but
|
|
|
## Available APIs
|
|
|
|
|
|
All built-in modules of Node.js are supported in Web Workers, and `asar`
|
|
|
-archives can still be read with Node.js APIs. However non of Electron's built-in
|
|
|
-modules can be used in multi-threaded environment.
|
|
|
+archives can still be read with Node.js APIs. However none of Electron's
|
|
|
+built-in modules can be used in a multi-threaded environment.
|
|
|
|
|
|
## Native Node.js modules
|
|
|
|
|
|
Any native Node.js module can be loaded directly in Web Workers, but it is
|
|
|
strongly recommended not to do so. Most existing native modules have been
|
|
|
-written assuming single-thread environment, using them in Web Workers will
|
|
|
+written assuming single-threaded environment, using them in Web Workers will
|
|
|
lead to crashes and memory corruptions.
|
|
|
|
|
|
-Even when using a thread-safe native Node.js module, it should be noticed that
|
|
|
-the `process.dlopen` function is not thread safe, so loading a native module
|
|
|
-in Web Workers is not thread safe.
|
|
|
+Note that even if a native Node.js module is thread-safe it's still not safe to
|
|
|
+load it in a Web Worker because the `process.dlopen` function is not thread
|
|
|
+safe.
|
|
|
|
|
|
The only way to load a native module safely for now, is to make sure the app
|
|
|
loads no native modules after the Web Workers get started.
|