Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/platform/lifecycle/node/sharedProcessLifecycleService.ts
3296 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { Emitter, Event } from '../../../base/common/event.js';
7
import { Disposable } from '../../../base/common/lifecycle.js';
8
import { createDecorator } from '../../instantiation/common/instantiation.js';
9
import { ILogService } from '../../log/common/log.js';
10
11
export const ISharedProcessLifecycleService = createDecorator<ISharedProcessLifecycleService>('sharedProcessLifecycleService');
12
13
export interface ISharedProcessLifecycleService {
14
15
readonly _serviceBrand: undefined;
16
17
/**
18
* An event for when the application will shutdown
19
*/
20
readonly onWillShutdown: Event<void>;
21
}
22
23
export class SharedProcessLifecycleService extends Disposable implements ISharedProcessLifecycleService {
24
25
declare readonly _serviceBrand: undefined;
26
27
private readonly _onWillShutdown = this._register(new Emitter<void>());
28
readonly onWillShutdown = this._onWillShutdown.event;
29
30
constructor(
31
@ILogService private readonly logService: ILogService
32
) {
33
super();
34
}
35
36
fireOnWillShutdown(): void {
37
this.logService.trace('Lifecycle#onWillShutdown.fire()');
38
39
this._onWillShutdown.fire();
40
}
41
}
42
43