Skip to content

luizberti/zync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zync

Custom synchronization primitives for Zig.

Thread Barrier (barrier.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 arrive

The 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.

Atomic Reference Counting (refcount.zig)

Work in progress. Currently attempting to port Rust's stdlib Arc design.

About

Synchronization primitives with Zig

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages