3 ms·
The trouble with I/O multiplexing in a language like C is that the callbacks and state machines get quite complex as you need more functionality. In C++ you can
by lukaslalinsky 1y ago
The trouble with I/O multiplexing in a language like C is that the callbacks and state machines get quite complex as you need more functionality. In C++ you can at least do closures, so it's easier to manage. I recently wanted to add networking to my Zig project and decided to do some yak shaving and implemented a fiber runtime with async I/O to avoid the callback complexity. https://github.com/lalinsky/zio https://github.com/lalinsky/zio
- nesarkvechnep 1y agoAs usual, no FreeBSD support.
- qudat 1y agoWow nice! How does this compare to libxev?
- jfadfwddas 1y agoI was curious as well and looks like this abstracts over libxev: https://github.com/lalinsky/zio/blob/main/build.zig#L7 https://github.com/lalinsky/zio/blob/main/build.zig#L7
- lukaslalinsky 1y agoIndeed, it's a translation of the callback-based libxev events to coroutines. I ended up temporarily forking libxev, to add support for vectored I/O and other small fixes, but all those changes will be upstreamed.
- jfadfwddas 1y agoGreat stuff. I will be using this if/when I go back to zigging :)
- spacechild1 1y agoIn C++20 you can use asio + coroutines. I find it pretty nice to work with.