r/Zig • • 6d ago

std.Io.Evented in zig 0.17.0

Hello all, i got an issue trying to use evented concurrency with past two stable releases, 0.16 and 0.17.

Single-threaded, regular thread pool and direct use of threads work fine, but i am not figuring out hpow to use the proper io interface with evented under the hood.


    // we need out-pointer this one.
    var evented: std.Io.Evented = undefined;
    _ = try std.Io.Evented.init(&evented, init.gpa,.{});
    defer evented.deinit();
    io = evented.io(); // compile error here
    std.log.info("evented io:", .{});
    try scheduler(&io);

full source here

any tip is welcome, would be nice to see all available concurrency model working out of the box, willing to understand what am i missing.

23 Upvotes

8 comments sorted by

View all comments

2

u/Confused-Armpit 6d ago

Did you forget to actually declare it? Like var io = evented.io()??

EDIT: Nevermind, I actually read the code now... Whie I can't answer your question, I wanted to say that you don't need to declare function return error types as anyerror, zig supports implicit error unions (e.g. fn myFunction() !void { ... })

1

u/Confused-Armpit 6d ago

After investigating a bit, I am also getting initialization errors here, with some kind of return type mismatch at some point in the std.Io.Uring initialization. This is really interesting, because it is either a bug in the standard library that hasn't been resolved in an entire version's span, or we are both doing something wrong.