Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
You can create a WebAssembly shared memory instance via the JavaScript API:
const memory = new WebAssembly.Memory({
initial: 80,
maximum: 80,
shared: true
You can then send this memory instance to a Web Worker via postMessage
:
const worker = new Worker("worker.js");
worker.postMessage({ memory });
The file worker.js
can then create a WebAssembly module using this shared memory instance, allowing it to be shared across module instance in different threads.
For a more complete example, see this blog post:
Faster Fractals with Multi-Threaded WebAssembly
–
–
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.