Sorry for being late to the party. I like the idea, it’s also close to something I’ve been brainstorming during this Christmas but I couldn’t get it done during the break so it’s left unfinished (and forgotten).
I’ve been trying many different approaches and I came to the conclusion that typical Promise/Future is a poor fit for Zig, and it’s basically inevitable to do co-routines with intrusive Loop/Queue. I did a quick PoC and I’ve also came to the conclusion that there should be some my.io.*
namespace. In my case it was flat struct, and it was accepting anytype
in every method, so it would be user-extensible but maybe I went too far with that. I can elaborate a bit more if you wish but IMHO it’s a bit of off-topic now.
Anyway, the next thing I wanted to implement in that PoC was structured concurrency because in my opinion, it’s something which has to be provided by the framework, otherwise it’s too easy to shoot yourself in the foot.
How is this Io
abstraction going to solve it? Sorry I did not watch the whole stream so I might be missing something but I skimmed through the codebase and examples and I don’t see any notion of nurseries or anything like that.
What I mean is that you have some “spawn point” where you can create new coroutines but they will all be cancelled if there is any uncaught error in that block, and it should also play nice with catch/defer/errdefer:
BTW: I think even Kotlin now has support for something like that.
BTW: The repo is here but there’s not much to see, it’s very bare PoC of coroutines. GitHub - cztomsik/nio.zig: TBD