def select.start

bend-kit-concurrency@0.2.0.0 · concurrency.bend:279

import bend-kit-concurrency@0.2.0.0/concurrency.bend as Concurrency
import Base

279# ponytail: relay fuel is the largest Nat literal, and a value takes three
280# steps, so a relay stops after about 1.4 billion values. Drop the fuel if
281# Base gains an unbounded loop.
282def select.start(
283  -A: Type, chans: List<Chan(A)>, +i: U32, +out: Chan(U32 & A), +done: Chan(Unit)
284) -> IO(Nat):
285  match chans:
286    case Nil{}:
287      IO.pure(Nat, 0n)
288    case src <> rest:
289      do IO<Nat>:
290        IO.spawn(Result<&1, &1, Unit, Unit>, select.relay(A, 4294967295n, i, src, out, done, RWait{}))
291        n : Nat <- select.start(A, rest, (i + 1 : U32), out, done)
292        return 1n+n

Uses (14)

Used by (1)