-
Book Overview & Buying
-
Table Of Contents
Systems Programming with Zig
By :
In this chapter, we have examined the fundamental transition from synchronous, blocking operations to the high-performance asynchronous model provided by Zig 0.16.x. We began by dismantling the common misconception that asynchrony and concurrency are identical, establishing instead how event loops like io_uring and kqueue allow a single thread to manage thousands of concurrent I/O events without the memory overhead of OS-level context switching. By implementing a TCP proxy, we moved from the theoretical mechanics of non-blocking code to a practical system capable of scaling under significant network load.
The next chapter puts these concurrency and networking primitives to work in a complete system: a production-ready in-memory cache server called zcache. It covers the internal data structures — a doubly linked list threaded through a hash map — that make O(1) eviction possible, a state machine for parsing a custom binary protocol arriving over a streaming...