ͯ͠ݻఆͷ int32 ྻͷ SharedArrayBuffer Λ͏ • Web Worker ݶఆͰɼόο ϑΝ্ͷ͕มΘΔͷΛ Atomics.wait Ͱಉظతʹ ͯΔ (futex(7)) const worker = new Worker('worker.js'); const buffer = new Int32Array( new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 1) ); new Worker('worker.js').postMessage(buffer); setTimeout(() => { // ࠷ॳͷཁૉΛ 0 ! 1 ʹॻ͖͑Δ Atomics.store(buffer, 0, 1); // ཁૉ͕ॻ͖Θͬͨ͜ͱΛ௨ͯ͠ϫʔΧʔΛى͜͢ Atomics.notify(buffer, 0, 1); }, 1000); onmessage = e => { const buffer = e.data; // 1ཁૉΛ0ΫϦΞ Atomics.store(buffer, 0, 0); // ͜͜Ͱ buffer ͕ॻ͖ΘΔ·Ͱ࣮ߦ͕ࢭ·Δ Atomics.wait(buffer, 0, 0); }; ϝΠϯεϨου ϫʔΧʔεϨου