Skip to content

Commit 738e5c6

Browse files
authored
eng - do not use native privates (microsoft#186737) (microsoft#186741)
1 parent 2e5a2f0 commit 738e5c6

File tree

1 file changed

+24
-26
lines changed

1 file changed

+24
-26
lines changed

src/vs/workbench/services/remote/common/remoteAgentService.ts

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
/* eslint-disable local/code-no-native-private */
7-
86
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
97
import { RemoteAgentConnectionContext, IRemoteAgentEnvironment } from 'vs/platform/remote/common/remoteAgentEnvironment';
108
import { IChannel, IServerChannel } from 'vs/base/parts/ipc/common/ipc';
@@ -74,55 +72,55 @@ export interface IRemoteConnectionLatencyMeasurement {
7472

7573
export const remoteConnectionLatencyMeasurer = new class {
7674

77-
readonly #maxSampleCount = 5;
78-
readonly #sampleDelay = 2000;
75+
readonly maxSampleCount = 5;
76+
readonly sampleDelay = 2000;
7977

80-
readonly #initial: number[] = [];
81-
readonly #maxInitialCount = 3;
78+
readonly initial: number[] = [];
79+
readonly maxInitialCount = 3;
8280

83-
readonly #average: number[] = [];
84-
readonly #maxAverageCount = 100;
81+
readonly average: number[] = [];
82+
readonly maxAverageCount = 100;
8583

86-
readonly #highLatencyMultiple = 2;
87-
readonly #highLatencyMinThreshold = 500;
88-
readonly #highLatencyMaxThreshold = 1500;
84+
readonly highLatencyMultiple = 2;
85+
readonly highLatencyMinThreshold = 500;
86+
readonly highLatencyMaxThreshold = 1500;
8987

90-
#lastMeasurement: IRemoteConnectionLatencyMeasurement | undefined = undefined;
91-
get latency() { return this.#lastMeasurement; }
88+
lastMeasurement: IRemoteConnectionLatencyMeasurement | undefined = undefined;
89+
get latency() { return this.lastMeasurement; }
9290

9391
async measure(remoteAgentService: IRemoteAgentService): Promise<IRemoteConnectionLatencyMeasurement | undefined> {
9492
let currentLatency = Infinity;
9593

9694
// Measure up to samples count
97-
for (let i = 0; i < this.#maxSampleCount; i++) {
95+
for (let i = 0; i < this.maxSampleCount; i++) {
9896
const rtt = await remoteAgentService.getRoundTripTime();
9997
if (rtt === undefined) {
10098
return undefined;
10199
}
102100

103101
currentLatency = Math.min(currentLatency, rtt / 2 /* we want just one way, not round trip time */);
104-
await timeout(this.#sampleDelay);
102+
await timeout(this.sampleDelay);
105103
}
106104

107105
// Keep track of average latency
108-
this.#average.push(currentLatency);
109-
if (this.#average.length > this.#maxAverageCount) {
110-
this.#average.shift();
106+
this.average.push(currentLatency);
107+
if (this.average.length > this.maxAverageCount) {
108+
this.average.shift();
111109
}
112110

113111
// Keep track of initial latency
114112
let initialLatency: number | undefined = undefined;
115-
if (this.#initial.length < this.#maxInitialCount) {
116-
this.#initial.push(currentLatency);
113+
if (this.initial.length < this.maxInitialCount) {
114+
this.initial.push(currentLatency);
117115
} else {
118-
initialLatency = this.#initial.reduce((sum, value) => sum + value, 0) / this.#initial.length;
116+
initialLatency = this.initial.reduce((sum, value) => sum + value, 0) / this.initial.length;
119117
}
120118

121119
// Remember as last measurement
122-
this.#lastMeasurement = {
120+
this.lastMeasurement = {
123121
initial: initialLatency,
124122
current: currentLatency,
125-
average: this.#average.reduce((sum, value) => sum + value, 0) / this.#average.length,
123+
average: this.average.reduce((sum, value) => sum + value, 0) / this.average.length,
126124
high: (() => {
127125

128126
// based on the initial, average and current latency, try to decide
@@ -137,18 +135,18 @@ export const remoteConnectionLatencyMeasurer = new class {
137135
return false;
138136
}
139137

140-
if (currentLatency > this.#highLatencyMaxThreshold) {
138+
if (currentLatency > this.highLatencyMaxThreshold) {
141139
return true;
142140
}
143141

144-
if (currentLatency > this.#highLatencyMinThreshold && currentLatency > initialLatency * this.#highLatencyMultiple) {
142+
if (currentLatency > this.highLatencyMinThreshold && currentLatency > initialLatency * this.highLatencyMultiple) {
145143
return true;
146144
}
147145

148146
return false;
149147
})()
150148
};
151149

152-
return this.#lastMeasurement;
150+
return this.lastMeasurement;
153151
}
154152
};

0 commit comments

Comments
 (0)