this post was submitted on 30 Aug 2023
1 points (100.0% liked)

Zig Programming Language

168 readers
3 users here now

A lemm.ee community for Zig!

founded 1 year ago
MODERATORS
 

Author's description:

An implementation of stackful asymmetric coroutines in Zig (and some assembly).

Allows for 3 kinds of usage: suspend/resume, yield/next (coroutine-based generators), and async/await.

Supports Mac, Linux, and Windows, x86_64 and aarch64 (x86_64 under CI on GitHub).

Planning on hooking this up with libuv or libxev soon so that I can start using async/await-like code before (stackless) async lands.

Source: Zig Discord

From the README:

Async Zig as a library using stackful asymmetric coroutines.

  • Stackful: each coroutine has an explicitly allocated stack and suspends/yields preserve the entire call stack of the coroutine. An ergonomic "stackless" implementation would require language support and that's what we expect to see with Zig's async functionality.
  • Asymmetric: coroutines are nested such that there is a "caller"/"callee" relationship, starting with a root coroutine per thread. The caller coroutine is the parent such that upon completion of the callee (the child coroutine), control will transfer to the caller. Intermediate yields/suspends transfer control to the last resuming coroutine.
no comments (yet)
sorted by: hot top controversial new old
there doesn't seem to be anything here