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

startup profiler listens on lifecycle event, #27852

上级 1d61c56f
......@@ -257,6 +257,15 @@ export function fromPromise(promise: TPromise<any>): Event<void> {
return emitter.event;
}
export function toPromise<T>(event: Event<T>): TPromise<T> {
return new TPromise(complete => {
const sub = event(e => {
sub.dispose();
complete(e);
});
});
}
export function delayed<T>(promise: TPromise<Event<T>>): Event<T> {
let toCancel: TPromise<any> = null;
let listener: IDisposable = null;
......@@ -511,4 +520,4 @@ export function echo<T>(event: Event<T>, nextTick = false, buffer: T[] = []): Ev
});
return emitter.event;
}
\ No newline at end of file
}
......@@ -179,6 +179,10 @@ export class WorkbenchShell {
// start cached data manager
instantiationService.createInstance(NodeCachedDataManager);
// Set lifecycle phase to `Runnning` so that other contributions
// can now do something
this.lifecycleService.phase = LifecyclePhase.Running;
}
});
......@@ -235,10 +239,6 @@ export class WorkbenchShell {
if ((platform.isLinux || platform.isMacintosh) && process.getuid() === 0) {
this.messageService.show(Severity.Warning, nls.localize('runningAsRoot', "It is recommended not to run Code as 'root'."));
}
// Set lifecycle phase to `Runnning` so that other contributions
// can now do something
this.lifecycleService.phase = LifecyclePhase.Running;
}
private initServiceCollection(container: HTMLElement): [IInstantiationService, ServiceCollection] {
......
......@@ -10,6 +10,7 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment'
import { IExtensionService } from 'vs/platform/extensions/common/extensions';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IMessageService } from 'vs/platform/message/common/message';
import { ILifecycleService, LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { ITimerService } from 'vs/workbench/services/timer/common/timerService';
import { IWindowsService } from 'vs/platform/windows/common/windows';
......@@ -20,6 +21,7 @@ import { ReportPerformanceIssueAction } from 'vs/workbench/electron-browser/acti
import { TPromise } from 'vs/base/common/winjs.base';
import { join } from 'path';
import { localize } from 'vs/nls';
import { toPromise, filterEvent } from 'vs/base/common/event';
import { platform, Platform } from 'vs/base/common/platform';
import { readdir, stat } from 'vs/base/node/pfs';
import { release } from 'os';
......@@ -149,10 +151,16 @@ class StartupProfiler implements IWorkbenchContribution {
@IMessageService private readonly _messageService: IMessageService,
@IEnvironmentService private readonly _environmentService: IEnvironmentService,
@IInstantiationService private readonly _instantiationService: IInstantiationService,
@ILifecycleService lifecycleService: ILifecycleService,
@IExtensionService extensionService: IExtensionService,
) {
extensionService.onReady().then(() => this._stopProfiling());
// wait for everything to be ready
TPromise.join<any>([
extensionService.onReady(),
toPromise(filterEvent(lifecycleService.onDidChangePhase, phase => phase === LifecyclePhase.Running)),
]).then(() => {
this._stopProfiling();
});
}
getId(): string {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册