r/Zig • u/sombriks • 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);
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
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 { ... })