The example WASM library show cases Crossbeam Channels and shared HashMap usage between workers.
- Install wasm-pack
- Install deno for static File HTTP server, see file-server-deno.ts 1
- Run
wasm-pack build
- Run
deno run --allow-run --allow-net --allow-read file-server-deno.ts
- Navigate to
http://localhost:8000
- Open a DevTools to see the communication in console
It initalizes only one WebAssembly.Memory
object and shares it between the workers. See index.js and worker.js for details.
1: If you don't want Deno, you still need a file server that is capable of setting headers Cross-Origin-Opener-Policy: same-origin
and Cross-Origin-Embedder-Policy: require-corp
, otherwise SharedArrayBuffer is not defined. See documentation.