in common/lib/plugins/efm2/monitor.ts [115:151]
async newContextRun(): Promise<void> {
logger.debug(Messages.get("MonitorImpl.startMonitoringTaskNewContext", this.hostInfo.host));
try {
while (!this.isStopped()) {
const currentTimeNanos = getCurrentTimeNano();
// Get entries with key (that is a time in nanos) less than current time.
const processedKeys: number[] = new Array<number>();
for (const [key, val] of MonitorImpl.newContexts.entries()) {
if (key < currentTimeNanos) {
const queue: Array<WeakRef<MonitorConnectionContext>> = val;
processedKeys.push(key);
// Each value of found entry is a queue of monitoring contexts awaiting active monitoring.
// Add all contexts to an active monitoring contexts queue.
// Ignore disposed contexts.
let monitorContextRef: WeakRef<MonitorConnectionContext> | undefined;
while ((monitorContextRef = queue?.shift()) != null) {
const monitorContext: MonitorConnectionContext = monitorContextRef?.deref() ?? null;
if (monitorContext && monitorContext.isActive()) {
this.activeContexts.push(monitorContextRef);
}
}
}
}
processedKeys.forEach((key) => {
MonitorImpl.newContexts.delete(key);
});
await sleep(1000);
}
return;
} catch (err) {
// do nothing, exit task
}
logger.debug(Messages.get("MonitorImpl.stopMonitoringTaskNewContext", this.hostInfo.host));
}