]> zoso.dev Git - libnemo.git/commitdiff
Ensure a minimum of one Pool core, even if nav.hwConc doesn't play nice.
authorChris Duncan <chris@zoso.dev>
Mon, 2 Dec 2024 22:25:31 +0000 (14:25 -0800)
committerChris Duncan <chris@zoso.dev>
Mon, 2 Dec 2024 22:25:31 +0000 (14:25 -0800)
src/lib/pool.ts

index d3c70a5ce24b676d91bcf2d5b3822abdfb97c917..9d9d47323a10831fbc37a2acfaf65fbeebe898ae 100644 (file)
@@ -18,7 +18,7 @@ type Thread = {
 * Processes an array of tasks using Web Workers.
 */
 export class Pool {
-       #cores: number = navigator.hardwareConcurrency - 1
+       #cores: number = Math.max(1, navigator.hardwareConcurrency ?? 1 - 1)
        #queue: object[] = []
        #resolve: Function = (value: unknown) => { }
        #results: object[] = []