提交 d2d9ecfc 编写于 作者: J Johannes Rieken

perf - use idle callback for lifecycle eventually contributions

上级 983299d9
......@@ -8,6 +8,7 @@
import { IInstantiationService, IConstructorSignature0 } from 'vs/platform/instantiation/common/instantiation';
import { ILifecycleService, LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
import { Registry } from 'vs/platform/registry/common/platform';
import { runWhenIdle, IdleDeadline } from 'vs/base/common/async';
// --- Workbench Contribution Registry
......@@ -93,11 +94,31 @@ class WorkbenchContributionsRegistry implements IWorkbenchContributionsRegistry
private doInstantiateByPhase(instantiationService: IInstantiationService, phase: LifecyclePhase): void {
const toBeInstantiated = this.toBeInstantiated.get(phase);
if (toBeInstantiated) {
// instantiate everything synchronously and blocking
for (const ctor of toBeInstantiated) {
instantiationService.createInstance(ctor);
}
this.toBeInstantiated.delete(phase);
if (phase !== LifecyclePhase.Eventually) {
// instantiate everything synchronously and blocking
for (const ctor of toBeInstantiated) {
instantiationService.createInstance(ctor);
}
} else {
// for the Eventually-phase we instantiate contributions
// only when idle. this might take a few idle-busy-cycles
// but will finish within the timeouts
let forcedTimeout = 3000;
let i = 0;
let instantiateSome = (idle: IdleDeadline) => {
while (i < toBeInstantiated.length) {
const ctor = toBeInstantiated[i++];
instantiationService.createInstance(ctor);
if (idle.timeRemaining() < 1) {
// time is up -> reschedule
runWhenIdle(instantiateSome, forcedTimeout);
break;
}
}
};
runWhenIdle(instantiateSome, forcedTimeout);
}
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册