MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / runAsync

Function runAsync

src/common/interruptible.ts:75–112  ·  view source on GitHub ↗
(
  gen: Generator<T>,
  timeLimitMs: number,
  signal?: AbortSignal
)

Source from the content-addressed store, hash-verified

73
74/**
75 * A budget of steps, armed by an internal span (`engine._withBudget`).
76 *
77 * A wall-clock budget makes a result depend on the speed and the load of the
78 * machine: the same integral closes on a fast machine and stays unevaluated on
79 * a slow one. A step budget does not. Each call of `checkDeadline` with a
80 * frame that holds this budget is one step, so the same computation on the
81 * same engine state spends the same number of steps on every machine.
82 *
83 * A nested span shares the object with its parent, so a step counts against
84 * every budget that is active. When `left` goes below zero, `checkDeadline`
85 * throws a `CancellationError` with `cause: 'step-budget'` and the budget's
86 * `owner` as its attribution. It is a budget expiry like the expiry of a
87 * labelled `withTimeLimit` span, and `isTimeoutCancellation` answers `true`
88 * for both, so the code that armed the budget can catch it and fall back,
89 * and every other catch block lets it through (`throwIfCallerCancellation`);
90 * the distinct cause lets a host tell a deterministic budget from the clock.
91 * Once spent, a budget stays spent: each later check throws again.
92 */
93export interface StepBudget {
94 left: number;
95 readonly owner?: string;
96 readonly spans: string[];
97 /**
98 * If true, a rule step (`checkDeadline(frame, true)`) counts against this
99 * budget too. A rule step is one rule tried by `replace()`. Only the
100 * budgets that were calibrated with rule steps set this, so that rule steps
101 * do not change the step count of the other budgets.
102 */
103 readonly ruleSteps?: boolean;
104 /**
105 * True for a budget that the public `withStepBudget` created, false or
106 * absent for one the engine opened for its own search (integration, Rubi,
107 * contour integrals). `ce.stepsLeft` reads the last budget with this flag,
108 * so host code that runs inside an engine search (an `evaluate` handler)
109 * still reads the host's budget.
110 */
111 readonly host?: true;
112}
113
114/**
115 * The paused time of one debug run of `executeEpsilAsync()`: the time while

Callers 2

arithmetic.tsFile · 0.90

Calls 1

nextMethod · 0.45

Tested by

no test coverage detected