autorunImpl.ts ×15

Frontier kind: Code frontier

unlabeled · c_27727eebbf80

916 tests · 6560 LOC · 59 files · introduces 0 tests · 71 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
15 ranges71 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
962 ranges6560 lines · 59 files · Browse complete extent
All tests (intent)
916 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.

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

src/vs/base/common/observableInternal/reactions/autorunImpl.ts 71 introduced LOC · 15 ranges

Open complete file

49
50 constructor(
51 > public readonly _debugNameData: DebugNameData, autorunImpl.ts
52 > public readonly _runFn: (reader: IReaderWithStore, changeSummary: TChangeSummary) => void,
53 > private readonly _changeTracker: IChangeTracker<TChangeSummary> | undefined,
54 > debugLocation: DebugLocation
55 > ) {
56 > this._changeSummary = this._changeTracker?.createChangeSummary(undefined);
57 > getLogger()?.handleAutorunCreated(this, debugLocation);
58 > this._run();
59 >
60 > trackDisposable(this);
61 > }
62
63 public dispose(): void {
64 > if (this._disposed) { autorunImpl.ts
65 return;
66 }
67 > this._disposed = true; autorunImpl.ts
68 > for (const o of this._dependencies) {
69 > o.removeObserver(this); // Warning: external call!
70 > }
71 > this._dependencies.clear();
72 >
73 > if (this._store !== undefined) {
74 this._store.dispose();
75 }
76 > if (this._delayedStore !== undefined) { autorunImpl.ts
77 this._delayedStore.dispose();
78 }
80 > getLogger()?.handleAutorunDisposed(this);
81 > markAsDisposed(this);
82 > }
83
84 private _run() {
85 > const emptySet = this._dependenciesToBeRemoved; autorunImpl.ts
86 > this._dependenciesToBeRemoved = this._dependencies;
87 > this._dependencies = emptySet;
88 >
89 > this._state = AutorunState.upToDate;
90 >
91 > try {
92 > if (!this._disposed) {
93 > getLogger()?.handleAutorunStarted(this);
94 > const changeSummary = this._changeSummary!;
95 > const delayedStore = this._delayedStore;
96 > if (delayedStore !== undefined) {
97 this._delayedStore = undefined;
98 }
99 > try { autorunImpl.ts
100 > this._isRunning = true;
101 > if (this._changeTracker) {
102 this._changeTracker.beforeUpdate?.(this, changeSummary);
103 this._changeSummary = this._changeTracker.createChangeSummary(changeSummary); // Warning: external call!
104 }
105 > if (this._store !== undefined) { autorunImpl.ts
106 this._store.dispose();
107 this._store = undefined;
108 }
110 > this._runFn(this, changeSummary); // Warning: external call!
111 > } catch (e) {
112 onBugIndicatingError(e);
113 > } finally { autorunImpl.ts
114 > this._isRunning = false;
115 > if (delayedStore !== undefined) {
116 delayedStore.dispose();
117 }
118 > } autorunImpl.ts
119 > }
120 > } finally {
121 > if (!this._disposed) {
122 > getLogger()?.handleAutorunFinished(this);
123 > }
124 > // We don't want our observed observables to think that they are (not even temporarily) not being observed.
125 > // Thus, we only unsubscribe from observables that are definitely not read anymore.
126 > for (const o of this._dependenciesToBeRemoved) {
127 o.removeObserver(this); // Warning: external call!
128 }
129 > this._dependenciesToBeRemoved.clear(); autorunImpl.ts
130 > }
131 > }
132
133 public toString(): string {
211
212 private _ensureNoRunning(): void {
213 > if (!this._isRunning) { throw new BugIndicatingError('The reader object cannot be used outside its compute function!'); } autorunImpl.ts
214 > }
215
216 public readObservable<T>(observable: IObservable<T>): T {
217 > this._ensureNoRunning(); autorunImpl.ts
218 >
219 > // In case the run action disposes the autorun
220 > if (this._disposed) {
221 return observable.get(); // warning: external call!
222 }
224 > observable.addObserver(this); // warning: external call!
225 > const value = observable.get(); // warning: external call!
226 > this._dependencies.add(observable);
227 > this._dependenciesToBeRemoved.delete(observable);
228 > return value;
229 > }
230
231 private _store: DisposableStore | undefined = undefined;