4 ms·
Would it work to use a Web Worker as the separate process? (Seems simpler than using a separate process with websockets).
by matharmin 9y ago
Would it work to use a Web Worker as the separate process? (Seems simpler than using a separate process with websockets).
- jlongster 9y agoNode doesn't have "web workers", so I'm not sure what you mean. Node doesn't come with threading support as far as I know; it's single-threaded by design, but there may be libraries that try to implement it.
- erulabs 9y agoNode does in fact come with "threading support", just in a non-obvious way (and not exactly exposed to the end-user). It depends on what module you're talking about, but libuv in general _does_ use a worker pool. For example, the "fs" module will, under the hood, make use of a thread pool. The "http" module use a different strategy depending on the operating system, etc. "Asynchronous system APIs are used by Node.js whenever possible, but where they do not exist, libuv's threadpool is used to create asynchronous node APIs based on synchronous system APIs." https://nodejs.org/api/cli.html#cli_uv_threadpool_size_size https://nodejs.org/api/cli.html#cli_uv_threadpool_size_size
- matharmin 9y agoNode doesn't by itself, but Electron does, and you may be able to use node modules such as a sqlite one inside it.
- Can_Not 9y agoYou actually can use child_process to make a worker thread, although it would make more sense to just have an async API.