From: Chris Duncan Date: Mon, 2 Dec 2024 22:25:31 +0000 (-0800) Subject: Ensure a minimum of one Pool core, even if nav.hwConc doesn't play nice. X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=08467053a354fa49836d993a7d9f41b39dca73d6;p=libnemo.git Ensure a minimum of one Pool core, even if nav.hwConc doesn't play nice. --- 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[] = []