A recv that gives up instead of blocking: the value and whether there was one.
Io :: #import "Extensions/Io";
Io.io_run(() {
channel := Io.make_channel(int, 1);
defer Io.free_channel(channel);
_, found := Io.try_recv(channel);
assert(!found);
Io.send(channel, 5);
value, found2 := Io.try_recv(channel);
assert(found2 && value == 5);
});try_recv :: (channel: *Channel($T)) -> (T, bool)
Parameters
- channel: *Channel($T)
Returns
- T
- bool