processor.ts ×13

Frontier kind: Code frontier

unlabeled · c_104fe54ad175

465 tests · 5239 LOC · 31 files · introduces 0 tests · 71 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
15 ranges71 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
701 ranges5239 lines · 31 files · Browse complete extent
All tests (intent)
465 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

2 files ranked by introduced lines: 71 introduced LOC across 15 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/base/test/common/virtualScheduling/processor.ts 69 introduced LOC · 13 ranges

Open complete file

63
64 constructor(
65 > public readonly options: RunOptions, processor.ts
66 > public readonly executedAtStart: number,
67 > public readonly maxEvents: number,
68 > ) {
69 > this.promise = new Promise<void>((res, rej) => { this._resolve = res; this._reject = rej; });
70 > }
71
72 settle(error?: Error): void {
73 > if (this._settled) { return; } processor.ts
74 > this._settled = true;
75 > if (error) { this._reject(error); } else { this._resolve(); }
76 > }
77
78 evaluate(clock: VirtualClock, executedTotal: number, makeOverflow: () => Error): RunStatus {
187
188 constructor(
189 > private readonly _clock: VirtualClock, processor.ts
190 > private readonly _embedding: Embedding,
191 > private readonly _realApi: TimeApi,
192 > opts: VirtualTimeProcessorOptions = {},
193 > ) {
194 > super();
195 > this._defaultMaxEvents = opts.defaultMaxEvents ?? 100;
196 > this._register({ dispose: () => this._onDispose() });
197 > }
198
199 // ---- Public API -----------------------------------------------------
201 /** Start a run with the given termination policy. */
202 run(options: RunOptions): Promise<void> {
203 > const run = new Run(options, this._executedTotal, options.maxEvents ?? this._defaultMaxEvents); processor.ts
204 > const cleanup = new DisposableStore();
205 >
206 > // Wake the loop on token cancellation so the run can re-evaluate.
207 > if (options.until.kind === 'token') {
208 cleanup.add(options.until.token.onCancellationRequested(() => this._wake()));
209 }
210 > processor.ts
211 > // For time-based termination, schedule a sentinel event at the
212 > // deadline. This guarantees virtual time reaches the deadline even if
213 > // the user never schedules anything else, and that the run does not
214 > // resolve early just because the queue happens to be empty *now*.
215 > if (options.until.kind === 'time' && options.until.time > this._clock.now) {
216 const source: EventSource = { toString: () => `<deadline of run #${run.id}>` };
217 cleanup.add(this._clock.schedule({
221 }));
222 }
223 > processor.ts
224 > this._runs.set(run, cleanup);
225 > this._wake();
226 > return run.promise;
227 > }
228
229 // ---- The pure step --------------------------------------------------
230
231 private _step(): StepOutcome {
232 > if (this._disposed) { return 'quiesce'; } processor.ts
233
234 this._settleFinishedRuns();
240 // Per-run trace-depth check: reject any run whose limit this event
241 // would exceed, before executing.
242 > const traceDepth = next.trace?.depth ?? 0; processor.ts
243 > let depthOverflow = false;
244 > for (const run of [...this._runs.keys()]) {
245 const limit = run.options.maxTraceDepth;
246 if (limit !== undefined && traceDepth > limit) {
253 this._executeOne(next);
254 return 'progress';
255 > } processor.ts
256
257 private _executeOne(event: VirtualEvent): void {
317
318 private _unpark(): void {
319 > this._parkCleanup?.dispose(); processor.ts
320 > this._parkCleanup = undefined;
321 > }
322
323 private _wake(): void {
324 > if (this._disposed) { return; } processor.ts
325 > this._unpark();
326 > // Re-enter the trampoline on a host macrotask, NOT a microtask. This:
327 > // - coalesces multiple wake() calls in the same tick,
328 > // - keeps the driver off the caller's stack frame, and
329 > // - lets the entire pending microtask closure (including microtasks
330 > // enqueued AFTER this `_wake` call within the same outer microtask
331 > // -- e.g. `queueMicrotask(...)` calls inside an `AsyncIterable`
332 > // constructor that runs after `clock.schedule` triggered the wake)
333 > // drain before the next `_step`. A microtask hop here would queue
334 > // the driver in FIFO order with those subsequent microtasks, so the
335 > // driver could run a virtual event before the consumer-side promise
336 > // chain that depends on it has settled.
337 > nextMacrotask(this._realApi, this._drive);
338 > }
339
340 // ---- Run lifecycle --------------------------------------------------
353
354 private _settleRun(run: Run, error?: Error): void {
355 > const cleanup = this._runs.get(run); processor.ts
356 > if (!cleanup) { return; }
357 > this._runs.delete(run);
358 > cleanup.dispose();
359 > run.settle(error);
360 > }
361
362 private _buildOverflow(run: Run): Error {
377
378 private _onDispose(): void {
379 > this._disposed = true; processor.ts
380 > this._unpark();
381 > const err = new Error('VirtualTimeProcessor disposed');
382 > for (const run of [...this._runs.keys()]) { this._settleRun(run, err); }
383 > }
384 }
src/vs/base/test/common/virtualScheduling/embedding.ts 2 introduced LOC · 2 ranges

Open complete file

64 */
65 export function drainMicrotasksEmbedding(realApi: TimeApi): Embedding {
66 > return (next, then) => { embedding.ts
67 if (next.preferRealAnimationFrame && realApi.requestAnimationFrame) {
68 realApi.requestAnimationFrame(() => then());
72 return 'cbScheduled';
73 };
74 > } embedding.ts
75
76 /**