Message Passing and Channels Between WASM Threads
Coordinate parallel WASM workers using message passing patterns and channel abstractions instead of raw shared memory.
Two Models of Concurrency
Concurrent systems coordinate either by sharing memory (SharedArrayBuffer + atomics) or by passing messages. Message passing avoids many data races by design.
postMessage Basics
Web Workers communicate with postMessage. Data is structured-cloned, so each side gets its own copy.
const worker = new Worker("worker.js");
worker.postMessage({ cmd: "start", n: 1000 });
worker.onmessage = (e) => console.log("result", e.data);All lessons in this course
- Web Workers with WASM Threads
- SharedArrayBuffer & Atomics for WASM
- Designing Concurrent WASM Applications
- Message Passing and Channels Between WASM Threads