Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/src/extension/power/common/powerService.ts
13399 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 { Event } from '../../../util/vs/base/common/event';
7
import { IDisposable } from '../../../util/vs/base/common/lifecycle';
8
import { createDecorator } from '../../../util/vs/platform/instantiation/common/instantiation';
9
10
export const IPowerService = createDecorator<IPowerService>('IPowerService');
11
12
export interface IPowerService {
13
readonly _serviceBrand: undefined;
14
15
/**
16
* Fires when the system is suspending (going to sleep).
17
*/
18
readonly onDidSuspend: Event<void>;
19
20
/**
21
* Fires when the system is resuming from sleep.
22
*/
23
readonly onDidResume: Event<void>;
24
25
/**
26
* Acquires a power save blocker that prevents app suspension.
27
* The blocker is reference-counted and will be released 2 minutes after
28
* the last acquisition is disposed.
29
*
30
* @returns A disposable that releases this acquisition when disposed.
31
*/
32
acquirePowerSaveBlocker(): IDisposable;
33
}
34
35
/**
36
* A no-op implementation of {@link IPowerService} for environments where
37
* power save blocking is not supported (e.g., web, headless, tests).
38
*/
39
export class NullPowerService implements IPowerService {
40
declare readonly _serviceBrand: undefined;
41
42
readonly onDidSuspend = Event.None;
43
readonly onDidResume = Event.None;
44
45
acquirePowerSaveBlocker(): IDisposable {
46
return { dispose: () => { } };
47
}
48
}
49
50