This commit is contained in:
Manav Rathi 2024-05-15 10:49:50 +05:30
parent c2fe134c92
commit d78628b66a
No known key found for this signature in database
4 changed files with 12 additions and 18 deletions

View file

@ -6,12 +6,11 @@ import { getToken, getUserID } from "@ente/shared/storage/localStorage/helpers";
import debounce from "debounce";
import PQueue from "p-queue";
import mlIDbStorage from "services/ml/db";
import { createFaceComlinkWorker } from "services/ml/face";
import type { DedicatedMLWorker } from "services/ml/face.worker";
import { MLSyncResult } from "services/ml/types";
import { EnteFile } from "types/file";
import { getDedicatedMLWorker } from "utils/comlink/ComlinkMLWorker";
import { DedicatedMLWorker } from "worker/ml.worker";
import { logQueueStats } from "./machineLearningService";
const LIVE_SYNC_IDLE_DEBOUNCE_SEC = 30;
const LIVE_SYNC_QUEUE_TIMEOUT_SEC = 300;
const LOCAL_FILES_UPDATED_DEBOUNCE_SEC = 30;
@ -226,7 +225,7 @@ class MLWorkManager {
// Live Sync
private async getLiveSyncWorker() {
if (!this.liveSyncWorker) {
this.liveSyncWorker = getDedicatedMLWorker("ml-sync-live");
this.liveSyncWorker = createFaceComlinkWorker("ml-sync-live");
}
return await this.liveSyncWorker.remote;
@ -274,7 +273,7 @@ class MLWorkManager {
// Sync Job
private async getSyncJobWorker() {
if (!this.syncJobWorker) {
this.syncJobWorker = getDedicatedMLWorker("ml-sync-job");
this.syncJobWorker = createFaceComlinkWorker("ml-sync-job");
}
return await this.syncJobWorker.remote;

View file

@ -0,0 +1,8 @@
import { ComlinkWorker } from "@/next/worker/comlink-worker";
import type { DedicatedMLWorker } from "services/ml/face.worker";
const createFaceWebWorker = () =>
new Worker(new URL("face.worker.ts", import.meta.url));
export const createFaceComlinkWorker = (name: string) =>
new ComlinkWorker<typeof DedicatedMLWorker>(name, createFaceWebWorker());

View file

@ -1,13 +0,0 @@
import { haveWindow } from "@/next/env";
import { ComlinkWorker } from "@/next/worker/comlink-worker";
import { type DedicatedMLWorker } from "worker/ml.worker";
export const getDedicatedMLWorker = (name: string) => {
if (haveWindow()) {
const cryptoComlinkWorker = new ComlinkWorker<typeof DedicatedMLWorker>(
name ?? "ente-ml-worker",
new Worker(new URL("worker/ml.worker.ts", import.meta.url)),
);
return cryptoComlinkWorker;
}
};