From: Chris Duncan Date: Mon, 16 Dec 2024 19:29:43 +0000 (-0800) Subject: Fix worker blob files being discarded as soon as the URL is lost. X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=e425ba340196eef357f99997be7a4802728ecf4d;p=libnemo.git Fix worker blob files being discarded as soon as the URL is lost. --- diff --git a/src/lib/pool.ts b/src/lib/pool.ts index 9431f2f..5211d2a 100644 --- a/src/lib/pool.ts +++ b/src/lib/pool.ts @@ -24,12 +24,12 @@ export class Pool { static #threads: Thread[] = [] static #cores: number = Math.max(1, navigator.hardwareConcurrency - 1) static #queue: Job[] = [] + static #url: string = URL.createObjectURL(new Blob([Workers], { type: 'text/javascript' })) static { - const url = URL.createObjectURL(new Blob([Workers], { type: 'text/javascript' })) for (let i = this.#cores; i > 0; i--) { const thread = { - worker: new Worker(url, { type: 'module' }), + worker: new Worker(this.#url, { type: 'module' }), job: null } thread.worker.addEventListener('message', message => {