Custom synchronization primitives for Zig.
A thread barrier that blocks all participating threads until every one of them has reached the synchronization point. Useful for lock-step parallel algorithms.
const zync = @import("zync");
// inside each of N worker threads:
zync.syncthreads(N); // blocks until all N threads arriveThe implementation uses atomic counting with a phase-based release mechanism. Waiting threads use an adaptive backoff strategy that progresses from spin-loop hints, through nanosleeps, to thread yields.
This was taken almost verbatim from Justine Tunney's syncthreads implementation.
Work in progress. Currently attempting to port Rust's stdlib Arc design.