Urgent.News

What's breaking now, across thousands of outlets.

Tech

Zig's Io.Threaded is Neat

Zig's std.Io.Threaded is a neat implementation of the Io interface that offers concurrency through blocking syscalls. It features deterministic parallelism, where you split the problem into independent partitions and implement a function to process each partition. Concurrency also involves cancellation, which is crucial when one asynchronous computation is no longer needed.

Zig's implementation of cancelation is more practical than others, as it allows you to cancel syscalls reliably. This is achieved by signaling a thread, which sets a flag in shared memory to request cancellation, and then signals the canceling thread until acknowledgment.

On POSIX, this is done by delivering signals to the thread, which wakes it up and returns EINTR from the blocked syscall. However, signals are inherently racy, so there's a protocol in place to ensure reliable cancelation. On Windows, there's a more direct NtCancelSynchronousIoFile mechanism. Zig's approach effectively handles concurrency between fibers, IO Completion Ports, Job objects, and more, providing a comprehensive concurrency story.

This is in contrast to Java's thread interruption mechanism, which doesn't support interrupting syscalls. In summary, Zig's std.Io.Threaded takes a unique approach to concurrency, separating "may run concurrently" from "must run concurrently" at the interface level, resulting in more precise signatures and easier understanding of the underlying processes.

Written by urgent.news from Lobsters's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at matklad.github.io →

More in Tech

Opus 5: Delete your CLAUDE.md?

Last week Y Combinator posted an interview with Boris Cherny, the engineer who built Claude Code, about the new Opus 5 release ( the full talk ).

  • Anthropic reduced system prompt in Claude Code by over 80% for Opus 5.
  • Engineers suggested deleting CLAUDE.md, skills, and hooks for non-agentic users.
  • Ablation process tested impact of each line in the compressed instruction file.

More from Thursday 6 August →