def pool.start

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

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

192def pool.start(
193  ~S: Type, ~A: Type, ~B: Type, ~work: S -> A -> IO(S & B), states: List<S>,
194  +fuel: Nat, +q: Chan(A & Chan(B))
195) -> IO(List<Chan(S)>):
196  match states:
197    case Nil{}:
198      IO.pure(List<Chan(S)>, Nil{})
199    case s <> rest:
200      do IO<List<Chan(S)>>:
201        c : Chan(S) <- IO.fork(S, pool.worker(~S, ~A, ~B, ~work, fuel, q, WIdle{s}))
202        cs : List<Chan(S)> <- pool.start(~S, ~A, ~B, ~work, rest, fuel, q)
203        return c <> cs

Uses (10)

Used by (1)