Nomenclature
This commit is contained in:
parent
381bffabbf
commit
1026974e23
|
@ -201,14 +201,14 @@ const ffmpegExec = async (
|
||||||
|
|
||||||
/** Lazily create a singleton instance of our worker */
|
/** Lazily create a singleton instance of our worker */
|
||||||
class WorkerFactory {
|
class WorkerFactory {
|
||||||
private _worker: ComlinkWorker<typeof DedicatedFFmpegWorker>;
|
private _comlinkWorker: ComlinkWorker<typeof DedicatedFFmpegWorker>;
|
||||||
private _instance: Promise<Remote<DedicatedFFmpegWorker>>;
|
private _instance: Promise<Remote<DedicatedFFmpegWorker>>;
|
||||||
|
|
||||||
async instance() {
|
async instance() {
|
||||||
if (!this._instance) {
|
if (!this._instance) {
|
||||||
const worker = createWorker();
|
const comlinkWorker = createComlinkWorker();
|
||||||
this._worker = worker;
|
this._comlinkWorker = comlinkWorker;
|
||||||
this._instance = worker.remote;
|
this._instance = comlinkWorker.remote;
|
||||||
}
|
}
|
||||||
return this._instance;
|
return this._instance;
|
||||||
}
|
}
|
||||||
|
@ -216,7 +216,7 @@ class WorkerFactory {
|
||||||
|
|
||||||
const workerFactory = new WorkerFactory();
|
const workerFactory = new WorkerFactory();
|
||||||
|
|
||||||
const createWorker = () =>
|
const createComlinkWorker = () =>
|
||||||
new ComlinkWorker<typeof DedicatedFFmpegWorker>(
|
new ComlinkWorker<typeof DedicatedFFmpegWorker>(
|
||||||
"ffmpeg-worker",
|
"ffmpeg-worker",
|
||||||
new Worker(new URL("worker/ffmpeg.worker.ts", import.meta.url)),
|
new Worker(new URL("worker/ffmpeg.worker.ts", import.meta.url)),
|
||||||
|
|
|
@ -30,7 +30,7 @@ class HEICConverter {
|
||||||
if (this.workerPool.length > 0) return;
|
if (this.workerPool.length > 0) return;
|
||||||
this.workerPool = [];
|
this.workerPool = [];
|
||||||
for (let i = 0; i < WORKER_POOL_SIZE; i++)
|
for (let i = 0; i < WORKER_POOL_SIZE; i++)
|
||||||
this.workerPool.push(createWorker());
|
this.workerPool.push(createComlinkWorker());
|
||||||
}
|
}
|
||||||
|
|
||||||
async convert(fileBlob: Blob): Promise<Blob> {
|
async convert(fileBlob: Blob): Promise<Blob> {
|
||||||
|
@ -96,7 +96,7 @@ class HEICConverter {
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log.error("heic conversion failed", e);
|
log.error("heic conversion failed", e);
|
||||||
convertWorker.terminate();
|
convertWorker.terminate();
|
||||||
this.workerPool.push(createWorker());
|
this.workerPool.push(createComlinkWorker());
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}, WAIT_TIME_BEFORE_NEXT_ATTEMPT_IN_MICROSECONDS),
|
}, WAIT_TIME_BEFORE_NEXT_ATTEMPT_IN_MICROSECONDS),
|
||||||
|
@ -117,7 +117,7 @@ class HEICConverter {
|
||||||
/** The singleton instance of {@link HEICConverter}. */
|
/** The singleton instance of {@link HEICConverter}. */
|
||||||
const converter = new HEICConverter();
|
const converter = new HEICConverter();
|
||||||
|
|
||||||
const createWorker = () =>
|
const createComlinkWorker = () =>
|
||||||
new ComlinkWorker<typeof DedicatedHEICConvertWorker>(
|
new ComlinkWorker<typeof DedicatedHEICConvertWorker>(
|
||||||
"heic-convert-worker",
|
"heic-convert-worker",
|
||||||
new Worker(new URL("worker/heic-convert.worker.ts", import.meta.url)),
|
new Worker(new URL("worker/heic-convert.worker.ts", import.meta.url)),
|
||||||
|
|
Loading…
Reference in a new issue