def tick.run

bend-kit-runner@0.13.0.1 · runner.bend:1605

import bend-kit-runner@0.13.0.1/runner.bend as Runner
import Base
import bend-kit-bytes@0.3.3.0/bytes.bend as Bytes
import bend-kit-retry@0.3.0.0/retry.bend as Retry

1605# Handles messages until no attempt runs and the inbox is empty. fuel bounds the messages; attempts that still run
1606# when it ends stay in the runner, and the next tick settles them.
1607def tick.run(~A: Data, ~penc: A -> Bytes.Bytes, ~target: A -> String, ~work: A -> IO(Retry.Outcome), fuel: Nat, +ran: Bool, k: Claimed(A)) ->
1608    IO(Runner<A> & Out(Bool)):
1609  match fuel:
1610    case 0n:
1611      (r, left, err) = k
1612      IO.pure(Runner<A> & Out(Bool), (r, tick.ran(err, ran)))
1613    case 1n+n:
1614      (r, +left, err) = k
1615      do IO<Runner<A> & Out(Bool)>:
1616        x : Runner<A> & Maybe<&1, Msg<A>> <- tick.next(A, r)
1617        tick.got(~A, ~penc, ~target, ~work, x, ran, left, err, (k2 => tick.run(~A, ~penc, ~target, ~work, n, True{}, k2)))

Uses (18)

Used by (2)