Live data from Hacker News

Zig's New Async I/O

kristoff.it

291–293 of 293 posts

Re: Zig's New Async I/O

#291
post #269
post #265

Earlier quoted context omitted.

That's the reason for the thread pool, and the resulting thread affinity issue.

This seems to assume that the same green thread will always run on the same native thread, which I don’t think is universally the case.

I don't understand why that matters.

Re: Zig's New Async I/O

#292

Earlier quoted context omitted.

> Afaik it's the only way to early-abort an operation since Goroutines operate in a cooperative, not preemptive, paradigm. I'm not sure what you mean here. Preemptive/coorporative terminology refers to interrupting (not aborting) a CPU-bound task, in which case goroutines are fully preemptive on most platforms since Go 1.14, check the release notes for more info. However, this has nothing to do with context. If you'r…

Goroutines are preemptive only to the runtime scheduler. You, the application developer merely using the language, cannot directly preempt a goroutine. This makes goroutines effectively cooperative still from the perspective of the developer. The preemptive runtime "just" prevents things like user code starving out the garbage collector. To interrupt a goroutine, your options are generally limited to context cancelat…

Exactly, thank you. I knew that the runtime gained the ability to preempt but the clear fact that you cannot get a handle to a goroutine (eg `gr := go fn()` is proof you have no way to take advantage of this ability as a user.

Re: Zig's New Async I/O

#293

I wrote a simple ssh server in zig to learn the language in my spare time. The new design makes the event loop / io much easier to reason about. Thanks Andy

Is there any chance you've published your project? It would be fun to read the code.

I’ll finish it this summer, hopefully.
Post reply on HN