Async and the New I/O Model

33.1 History

Zig ≤ 0.10 had language-level async/await/suspend/resume (stackless coroutines).

They were removed in 0.11 when the self-hosted compiler replaced the old C++ one. The keywords remain reserved.

33.2 The std.Io Direction

The redesign makes asynchrony an interface: functions take an Io parameter (like an allocator) and call io.async(...) / future.await(io). The caller picks the implementation: blocking (thread-based), a thread pool, or an event loop (io_uring/kqueue/IOCP, green threads/stackless coroutines).

Goal: write I/O code once and run it synchronously or asynchronously without "function coloring".

0.15 shipped the new std.Io.Writer/Reader as the first step. The Io interface for async and concurrency is landing in subsequent releases (0.16+).

Check the release notes for your version. APIs in this area change rapidly.

33.3 Practical Async I/O Today

Threads plus blocking I/O (simple, scales to thousands of connections).

Event-loop libraries: libxev (io_uring/kqueue/IOCP, used by Ghostty), zig-aio, tardy, and std.os.linux.IoUring directly.

Web servers: http.zig (thread pool + epoll/kqueue), zap (wraps facil.io).