From ebf91bb61c0110d3800d2a9b0131dbcf7b16f855 Mon Sep 17 00:00:00 2001 From: MrBounty Date: Wed, 22 Jan 2025 10:29:54 +0100 Subject: [PATCH] If config.CPU_CORE == 0, use the cpu count of processor --- src/thread/engine.zig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/thread/engine.zig b/src/thread/engine.zig index 5ed8cfe..9f1b96c 100644 --- a/src/thread/engine.zig +++ b/src/thread/engine.zig @@ -17,10 +17,13 @@ pub fn init(allocator: std.mem.Allocator) !ThreadEngine { .child_allocator = allocator, }; + const cpu_core = if (CPU_CORE == 0) try std.Thread.getCpuCount() else CPU_CORE; + log.info("Using {d} cpu core", .{cpu_core}); + const thread_pool = try allocator.create(std.Thread.Pool); thread_pool.init(std.Thread.Pool.Options{ .allocator = thread_arena.allocator(), - .n_jobs = CPU_CORE, + .n_jobs = cpu_core, }) catch @panic("=("); return ThreadEngine{