From d90c5675b9f061e3bfaaa7849c9330e1c2f4cf70 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Tue, 3 Dec 2024 15:23:36 -0800 Subject: [PATCH] Per typescript, navigator.hardwareConcurrency is never null, so lose the fallback to 1. Also limit to 80% cpu instead of almost maxing out. --- 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 5cafabd..5524879 100644 --- a/src/lib/pool.ts +++ b/src/lib/pool.ts @@ -19,7 +19,7 @@ type Thread = { */ export class Pool { #approach: 'converge' | 'divide' = 'divide' - #cores: number = Math.max(1, (navigator.hardwareConcurrency || 1) - 1) + #cores: number = Math.max(1, Math.floor(navigator.hardwareConcurrency * 0.8)) #queue: object[] = [] #resolve: Function = (value: unknown): void => { } #results: object[] = [] -- 2.34.1