Server.server.loop.go: def of emerging-ezhttp@0.21.0.0 Import: import emerging-ezhttp@0.21.0.0/src/server.bend as Server Lines 401-420 of emerging-ezhttp@0.21.0.0/src/server.bend: https://jend.leeeet.dev/read.txt?path=emerging-ezhttp@0.21.0.0/src/server.bend&start_line=401&end_line=420 import Base import emerging-ezhttp@0.21.0.0/src/step.bend as Step # the limited accept loop: `fuel` connections left, `idles` idle accepts in # a row left, `forks` forked so far def server.loop.go(~C: Data, ~handle: C -> Req -> IO(Answer), +ctx: C, fuel: Nat, idles: Nat, +forks: Nat, +slots: Chan(Unit), +limited: Bool, +done: Chan(Unit), listener: Listener) -> IO(Unit): match fuel idles: case 0n _: IO.bind(Unit, Unit, Listener.close(listener), _u => server.join(forks, done)) case 1n+_f 0n: IO.bind(Unit, Unit, Listener.close(listener), _u => server.join(forks, done)) case 1n+f0 1n+i: +f = f0 IO.bind(Listener & Step.Accept, Unit, server.accept(listener), r => server.loop.got(~C, handle, ctx, slots, limited, done, True{}, r, l => server.loop.go(~C, handle, ctx, f, server.idles(), 1n+forks, slots, limited, done, l), l => server.loop.go(~C, handle, ctx, 1n+f, i, forks, slots, limited, done, l), l => server.loop.go(~C, handle, ctx, f, server.idles(), forks, slots, limited, done, l))) Uses (17): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool 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=Listener https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Listener.close 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=Socket https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Unit https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/src/server.bend&name=Answer https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/src/server.bend&name=Req https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/src/server.bend&name=server.accept https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/src/server.bend&name=server.idles https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/src/server.bend&name=server.join https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/src/server.bend&name=server.loop.got https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/src/step.bend&name=Accept