Line data Source code
1 : /// The latest analyzed result of every result owner, e.g. a session script.
2 : ///
3 : /// The computation of a result replaces the computation of the owner's previous result once it is
4 : /// analyzed, the previous result stays until then. A result that is analyzed after a later result of
5 : /// the same owner, e.g. of an overlapping rerun, is stale.
6 1 : export class ResultComputations {
7 : /// The latest analyzed query of every owner
8 1 : private readonly latest = new Map<string, number>();
9 :
10 : /// Register the analyzed result of an owner, returns the computation that is no longer needed
11 1 : retain(owner: string, queryId: number): number | null {
12 1 : const latest = this.latest.get(owner);
13 1 : if (latest !== undefined && latest > queryId) {
14 1 : return queryId;
15 : }
16 1 : this.latest.set(owner, queryId);
17 1 : return latest ?? null;
18 1 : }
19 1 : }
|