#Wait for one of any Io.Future

1 messages · Page 1 of 1 (latest)

worn sentinel
#

While I asked this question in #zig, I think I need additional help to understand how and what I need to make it work.

I have a list of all map of all futures (all_futures: std.AutoHashMap(usize, std.Io.Future(void))), and a subset list of handles to wait for (handles: []usize).

How could I wait for the first future in the subset to finish:

fn waitAny(io: std.Io, all_futures: std.AutoHashMap(usize, std.Io.Future(void)), handles: []usize) void

I've been directed to std.Io.Select, but I am unsure how to use it, since my futures are already spawned by the time I need to select one.

paper mantle
#

how do you get the futures, and is the hashmap key used elsewhere

jaunty summit
#

std.Io is completion based rather poll based so you can't poll a future. You could look at how std.Io.Select does it. It uses std.Io.Group + std.Io.Queue

paper mantle
#

you should be able to just change your all_futures to a Select, but if it doesnt work the way you need you can make your own abstraction, @jaunty summit told you how Select was implemented for you to go off of.