Skip to main content
100%

Safe flag test (emscripten)

✓ Published0🌍 Public
Aadamscott
Last edited Jul 12, 2025
Created on Jul 11, 2025

This example demonstrates a safe-flag test for WebAssembly threads, showing atomic boolean operations across thread creation and joins. The program stores and loads a boolean with `memory_order_release` and `memory_order_acquire` semantics, printing its value from both the main thread and a spawned thread. It builds with SCons using the Emscripten toolchain, enabling pthreads via `-sUSE_PTHREADS=1` and shared memory, while the C++17 code relies on `std::atomic_bool` and `std::thread`. The visualization compiles to `index.html`, `index.js`, and `index.wasm` for browser execution.

AI-generated description

Similar vizzes