zync
zync (attempt at wordplay on “sync” and “zinc”) is a concurrency programming toolkit for zig, inspired by libraries such as crossbeam, ConcurrencyKit and cds. At the moment, the project is still very early in development.
So far it has:
- Safe memory reclamation: epoch-based reclamation which is what lets the lock-free structures free nodes safely without a GC.
- Data structures: Treiber stack, SPSC ring, and bounded & unbounded MPMC queues.
- Locks & utils: ticket/spin/seq locks, exponential backoff, cache padded type, atomic fences, etc.
This was mostly written as a learning/research exercise and because something like this is missing currently in the Zig ecosystem.
The current plans are roughly:
- More data structures (lock-free hashmap, work-stealing deque, better queues)
- Channels (synchronous, for async ones, see
zio)
I am not sure how large the scope should be, but it could also include in the future alternative safe memory reclamation mechanisms like Hazard Pointers or QSBR.
I’d love to get feedback on design choices, implementation and scope.
zig 0.16 is required, but the code barely depends on std at all, so it should be fairly portable, even to freestanding targets.