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

Function run

src/common/interruptible.ts:114–132  ·  view source on GitHub ↗
(gen: Generator<T>, timeLimitMs: number)

Source from the content-addressed store, hash-verified

112 this.name = 'CancellationError';
113 if (cause === 'iteration-limit-exceeded') _iterationLimitCancellations += 1;
114 }
115}
116
117/**
118 * Throw a `CancellationError` if `deadline` (an absolute timestamp in
119 * milliseconds, or a `DeadlineFrame`, i.e. `engine._deadline` /
120 * `engine._deadlineFrame`) has passed.
121 *
122 * When passed a `DeadlineFrame`, the thrown error carries `attribution`
123 * (the frame's `owner`) and `spans` so the catching code can tell which
124 * budget fired.
125 *
126 * Call this periodically from long-running loops that cannot be expressed
127 * as generators (where `run()`/`runAsync()` would apply). In tight loops,
128 * amortize the `Date.now()` cost with a stride counter:
129 *
130 * if ((++count & 0x3ff) === 0) checkDeadline(ce._deadlineFrame);
131 */
132export function checkDeadline(
133 deadline: number | DeadlineFrame | undefined
134): void {
135 if (deadline === undefined) return;

Callers 6

collections.tsFile · 0.90
arithmetic.tsFile · 0.90
nDSolveFunction · 0.50
solveOverDomainFunction · 0.50
solveOverMultipleDomainsFunction · 0.50

Calls 1

nextMethod · 0.45

Tested by

no test coverage detected