forked from Blendman974/faceclaw
Clean up unused worker threads for closed apps; other performance optimizations
This commit is contained in:
1 parent
9560f3ac8d
commit
2e4d20e130
20 files changed
+360
-13
No files matched your search
@@ -18,6 +18,12 @@ function markChanged(key: string): void {
|
||||
}
|
||||
let pollTimer: ReturnType<typeof setInterval> | null = null
|
||||
const listeners = new Set<(key: string) => void>()
|
||||
export function disposeSettingsStore(): void {
|
||||
listeners.clear()
|
||||
if (pollTimer !== null) clearInterval(pollTimer)
|
||||
pollTimer = null
|
||||
observed.clear()
|
||||
}
|
||||
function changed(key: string): void {
|
||||
setTimeout(() => { for (const listener of [...listeners]) listener(key) }, 0)
|
||||
}
|
||||
|
||||
@@ -14,6 +14,13 @@ let javaInstance: any = null;
|
||||
let retainedListenerProxy: any = null;
|
||||
const changeListeners = new Set<(key: string) => void>();
|
||||
|
||||
/** Release this isolate's native observer before its worker is terminated. */
|
||||
export function disposeSettingsStore(): void {
|
||||
changeListeners.clear();
|
||||
if (retainedListenerProxy !== null) getJava().unregisterListener(retainedListenerProxy);
|
||||
retainedListenerProxy = null;
|
||||
}
|
||||
|
||||
function getJava(): any {
|
||||
if (javaInstance === null) {
|
||||
const context = Utils.android?.getApplicationContext?.();
|
||||
|
||||
Reference in new issue
Block a user