ECMA-2017(ES8), just finalized about a month ago, introduces SharedArrayBuffer and Atomics. The link here shows that they have been supported in some browsers.
As we know, they are meant to allow the sharing of data across threads. I wonder how this kind of parallelism is achieved in browsers and Node? Are we supposed to use Web Workers and the 'cluster' package respectively?
Indeed, for browsers SharedArrayBuffers
and Atomics
are intended to be used with WebWorkers, which is the natural way to have code run in concurrent threads in a browser context.
For Node.js, the threads spawned with the cluster package would indeed be candidates for sharing data, but at the time of writing there is no implementation of SharedArrayBuffers
in Node.js yet, so this is theory. You may want to scan several discussions about it:
There already is the ems package which allows sharing data between different threads and processes.
Related:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With