When will we get the updated guide of new async await?

Hi,
I am beginner to zig and I need a guide to understand a topic properly.
Using zig.guide I have learn a lot and the standard library docs seems bit complicated to me.
I heard the recent news of new async await of std.Io (capital “i”), and want to learn more about it.
So I am interested to know when can I expect the current zig version (0.16.0/0.15.1) guide ?

Thanks in advanced

@kristoff blogged about the new async/await a little while ago:

TL;DR: it will be used via IO interface methods instead of language syntax sugar:

const std = @import("std");
const Io = std.Io;

fn saveData(io: Io, data: []const u8) !void {
   var a_future = io.async(saveFile, .{io, data, "saveA.txt"});
   defer a_future.cancel(io) catch {};

   var b_future = io.async(saveFile, .{io, data, "saveB.txt"});
   defer b_future.cancel(io) catch {};

   // We could decide to cancel the current task
   // and everything would be realeased correctly.
   // if (true) return error.Canceled;

   try a_future.await(io);
   try b_future.await(io);

   const out: Io.File = .stdout();
   try out.writeAll(io, "save complete");
}

fn saveFile(io: Io, data: []const u8, name: []const u8) !void {
   const file = try Io.Dir.cwd().createFile(io, name, .{});
   defer file.close(io);
   try file.writeAll(io, data);
}

…but tbh, I wouldn’t worry about async/await until it arrives and is usable, and most Zig code probably won’t need to worry about async/await either.

8 Likes