@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
25 lines • 1.22 kB
TypeScript
export declare const YIELD_INTERVAL = 2;
export declare const YIELD_CALLS = 4096;
/**
* A per-consumer time budget between opportunities for timers and
* cancellation. `check` runs beside the signal, for a deadline it does not
* carry. A busy consumer yields every `YIELD_INTERVAL` ms, the turn Python's
* twin takes under the daemon's 1 ms GIL switch interval: the twin yields every
* two switch intervals, as a loop that yields more often keeps its other
* threads from the GIL, while this one runs every workspace on one thread. A
* budget also yields after `YIELD_CALLS` runs, whichever comes first, and
* starts at its first `run`, as the twin does.
* The interval is read on `performance.now()`, the clock fake timers replace
* along with the timer its yield waits on; where that clock stands still while
* a task computes, the call bound is what lets a busy line be cancelled.
*/
export declare class YieldBudget {
private readonly signal?;
private readonly check?;
private nextYield;
private calls;
constructor(signal?: AbortSignal | undefined, check?: (() => void) | undefined);
run(): Promise<void> | undefined;
private yield;
}
//# sourceMappingURL=yield_budget.d.ts.map