Concurrency.pool.run: def of bend-kit-concurrency@0.2.0.0 Import: import bend-kit-concurrency@0.2.0.0/concurrency.bend as Concurrency Lines 215-228 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=215&end_line=228 import Base def pool.run( ~S: Type, ~A: Type, ~B: Type, ~work: S -> A -> IO(S & B), states: List, nx: Nat & List ) -> IO(List & List): (+n, xs) = nx do IO & List>: queue : Chan(A & Chan(B)) <- Chan.new(A & Chan(B), U32.from_nat(n)) +q : Chan(A & Chan(B)) = queue replies : List <- pool.put(~A, ~B, xs, q) Chan.close(A & Chan(B), q) workers : List <- pool.start(~S, ~A, ~B, ~work, states, Nat.mul(3n, 1n+n), q) outs : List <- pool.join(B, replies) done : List <- pool.join(S, workers) return (done, outs) Uses (16): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Chan https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Chan.close https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Chan.new 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=List https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.mul https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Pair https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Sigma https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.from_nat 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=pool.join https://jend.leeeet.dev/definition.txt?path=bend-kit-concurrency@0.2.0.0/concurrency.bend&name=pool.put https://jend.leeeet.dev/definition.txt?path=bend-kit-concurrency@0.2.0.0/concurrency.bend&name=pool.start