]> zoso.dev Git - libnemo.git/commitdiff
Fix worker blob files being discarded as soon as the URL is lost.
authorChris Duncan <chris@zoso.dev>
Mon, 16 Dec 2024 19:29:43 +0000 (11:29 -0800)
committerChris Duncan <chris@zoso.dev>
Mon, 16 Dec 2024 19:29:43 +0000 (11:29 -0800)
src/lib/pool.ts

index 9431f2f49050ea14c9ba82f3ec113c6b527d17b9..5211d2a38ca8c03a8ae7fd2043a36b0f690169ee 100644 (file)
@@ -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 => {