mitchellh / libxev

libxev is a cross-platform, high-performance event loop that provides abstractions for non-blocking IO, timers, events, and more and works on Linux (io_uring or epoll), macOS (kqueue), and Wasm + WASI. Available as both a Zig and C API.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is this based on callbacks? Is it possible to be `async` based?

zfl9 opened this issue · comments

commented

I've looked at the readme example, and it seems to be very similar to the C libev library, which is based on callbacks.

When there's a lot of business, this can lead to callback hell, and that's really cumbersome, is it possible to avoid callback hell by using zig's async functionality?

i.e. writing code in a "synchronous" coding style, but the underlying code is still "asynchronous and non-blocking".

Given Zig 0.10 and 0.11 don't support async, this isn't something I even attempted to do yet. Computers aren't magic, it's all kind of the same, we'd just have to figure out a way to store a frame which would probably add some overhead to the completions. So I'm sure there is a way to do it but it's always going to be a tradeoff. I'll look more into it once Zig supports async again.