From 08467053a354fa49836d993a7d9f41b39dca73d6 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Mon, 2 Dec 2024 14:25:31 -0800 Subject: [PATCH] Ensure a minimum of one Pool core, even if nav.hwConc doesn't play nice. --- src/lib/pool.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/pool.ts b/src/lib/pool.ts index d3c70a5..9d9d473 100644 --- a/src/lib/pool.ts +++ b/src/lib/pool.ts @@ -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[] = [] -- 2.34.1