@100mslive/hms-video-store 0.12.40-alpha.3 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
export declare type CPUPressureState = 'nominal' | 'fair' | 'serious' | 'critical';
|
|
2
2
|
/**
|
|
3
3
|
* Monitors CPU pressure using the Compute Pressure API (PressureObserver)
|
|
4
|
-
* and provides the current pressure state on demand
|
|
4
|
+
* and provides the current pressure state on demand.
|
|
5
5
|
*/
|
|
6
6
|
export declare class CPUPressureMonitor {
|
|
7
7
|
private observer;
|
|
8
|
+
private currentState;
|
|
8
9
|
private TAG;
|
|
9
10
|
constructor();
|
|
10
11
|
private init;
|
|
11
12
|
/**
|
|
12
|
-
* Get the current CPU pressure state
|
|
13
|
+
* Get the current CPU pressure state
|
|
13
14
|
*/
|
|
14
15
|
getCurrentState(): CPUPressureState;
|
|
15
16
|
/**
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.13.0",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
@@ -73,5 +73,5 @@
|
|
|
73
73
|
"conferencing",
|
|
74
74
|
"100ms"
|
|
75
75
|
],
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "53c008cf9dbbda1753d7353184fc8c6e60d34ed4"
|
|
77
77
|
}
|
|
@@ -9,10 +9,11 @@ interface PressureRecord {
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Monitors CPU pressure using the Compute Pressure API (PressureObserver)
|
|
12
|
-
* and provides the current pressure state on demand
|
|
12
|
+
* and provides the current pressure state on demand.
|
|
13
13
|
*/
|
|
14
14
|
export class CPUPressureMonitor {
|
|
15
15
|
private observer: any;
|
|
16
|
+
private currentState: CPUPressureState = 'nominal';
|
|
16
17
|
private TAG = '[CPUPressureMonitor]';
|
|
17
18
|
|
|
18
19
|
constructor() {
|
|
@@ -27,7 +28,11 @@ export class CPUPressureMonitor {
|
|
|
27
28
|
|
|
28
29
|
try {
|
|
29
30
|
// @ts-ignore - PressureObserver is not yet in TypeScript definitions
|
|
30
|
-
this.observer = new PressureObserver(() => {
|
|
31
|
+
this.observer = new PressureObserver((records: PressureRecord[]) => {
|
|
32
|
+
if (records.length > 0) {
|
|
33
|
+
this.currentState = records[records.length - 1].state;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
31
36
|
|
|
32
37
|
await this.observer.observe('cpu', {
|
|
33
38
|
sampleInterval: 1000, // 1 second
|
|
@@ -40,23 +45,10 @@ export class CPUPressureMonitor {
|
|
|
40
45
|
}
|
|
41
46
|
|
|
42
47
|
/**
|
|
43
|
-
* Get the current CPU pressure state
|
|
48
|
+
* Get the current CPU pressure state
|
|
44
49
|
*/
|
|
45
50
|
getCurrentState(): CPUPressureState {
|
|
46
|
-
|
|
47
|
-
return 'nominal';
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
try {
|
|
51
|
-
const records: PressureRecord[] = this.observer.takeRecords();
|
|
52
|
-
if (records.length > 0) {
|
|
53
|
-
return records[records.length - 1].state;
|
|
54
|
-
}
|
|
55
|
-
} catch (error) {
|
|
56
|
-
HMSLogger.e(this.TAG, 'Error taking CPU pressure records', error);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return 'nominal';
|
|
51
|
+
return this.currentState;
|
|
60
52
|
}
|
|
61
53
|
|
|
62
54
|
/**
|