Concurrency.select.start: def of bend-kit-concurrency@0.2.0.0 Import: import bend-kit-concurrency@0.2.0.0/concurrency.bend as Concurrency Lines 279-292 of bend-kit-concurrency@0.2.0.0/concurrency.bend: https://jend.leeeet.dev/read.txt?path=bend-kit-concurrency@0.2.0.0/concurrency.bend&start_line=279&end_line=292 import Base # ponytail: relay fuel is the largest Nat literal, and a value takes three # steps, so a relay stops after about 1.4 billion values. Drop the fuel if # Base gains an unbounded loop. def select.start( -A: Type, chans: List, +i: U32, +out: Chan(U32 & A), +done: Chan(Unit) ) -> IO(Nat): match chans: case Nil{}: IO.pure(Nat, 0n) case src <> rest: do IO: IO.spawn(Result<&1, &1, Unit, Unit>, select.relay(A, 4294967295n, i, src, out, done, RWait{})) n : Nat <- select.start(A, rest, (i + 1 : U32), out, done) return 1n+n Uses (14): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Chan https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=IO https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=IO.bind https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=IO.pure https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=IO.spawn https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Pair https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Result https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.add https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Unit https://jend.leeeet.dev/definition.txt?path=bend-kit-concurrency@0.2.0.0/concurrency.bend&name=Relay https://jend.leeeet.dev/definition.txt?path=bend-kit-concurrency@0.2.0.0/concurrency.bend&name=select.relay