From: Chris Duncan Date: Tue, 3 Dec 2024 23:23:36 +0000 (-0800) Subject: Per typescript, navigator.hardwareConcurrency is never null, so lose the fallback... X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=d90c5675b9f061e3bfaaa7849c9330e1c2f4cf70;p=libnemo.git Per typescript, navigator.hardwareConcurrency is never null, so lose the fallback to 1. Also limit to 80% cpu instead of almost maxing out. --- 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[] = []