// Two ready receive arms: the scheduler's seeded draw picks one; the other value is // received afterwards; the sum does not depend on the draw. // expect: run // grant: heap=mem.alloc:64 // schedules: 20 // result: 3 // equivalent: phase3/run/select_ready_draw.air // phase: 6 // spec: docs/spec/15-source-language.md module demo.selectdraw fn main(heap: cap) -> u64 effects [mem.alloc, task.wait] { match channel.make(1, heap) { ok(ta, ra) => { match channel.make(1, heap) { ok(tb, rb) => { channel.send(ta, 1u64) or trap; channel.send(tb, 2u64) or trap; channel.close_sender(move ta); channel.close_sender(move tb); var sum: u64 = 0; select { recv(ra) { ok(x) => { sum = x + (channel.recv(rb) or trap); } closed => { trap; } } recv(rb) { ok(y) => { sum = y + (channel.recv(ra) or trap); } closed => { trap; } } cancelled => { trap; } } channel.close_receiver(move ra) or trap; channel.close_receiver(move rb) or trap; sum } err(e) => { trap; } } } err(e) => { trap; } } }