// Shared memory between main thread and workers using int32atomic. // Requires Node v24+. // // Run: node examples/atomics/main.ts import { workers, int32atomic } from '../../src/index.ts'; import { increment } from './increment.ts'; const counter = int32atomic(); { using run = workers(4); // Fire off 100 increments across 4 workers await Promise.all(Array.from({ length: 100 }, () => run(increment(counter)))); } console.log(`Expected: 100`); console.log(`Actual: ${counter.load()}`);