Commit 3a276be135

kprotty <kbutcher6200@gmail.com>
2021-06-20 04:50:34
std.Thread.getCpuCount(): fix usages
1 parent 0a1def7
Changed files (3)
lib
std
src
lib/std/event/loop.zig
@@ -137,7 +137,7 @@ pub const Loop = struct {
     }
 
     /// After initialization, call run().
-    /// This is the same as `initThreadPool` using `Thread.cpuCount` to determine the thread
+    /// This is the same as `initThreadPool` using `Thread.getCpuCount` to determine the thread
     /// pool size.
     /// TODO copy elision / named return values so that the threads referencing *Loop
     /// have the correct pointer value.
@@ -145,7 +145,7 @@ pub const Loop = struct {
     pub fn initMultiThreaded(self: *Loop) !void {
         if (builtin.single_threaded)
             @compileError("initMultiThreaded unavailable when building in single-threaded mode");
-        const core_count = try Thread.cpuCount();
+        const core_count = try Thread.getCpuCount();
         return self.initThreadPool(core_count);
     }
 
lib/std/os/test.zig
@@ -364,7 +364,7 @@ fn start2(ctx: *i32) u8 {
 test "cpu count" {
     if (native_os == .wasi) return error.SkipZigTest;
 
-    const cpu_count = try Thread.cpuCount();
+    const cpu_count = try Thread.getCpuCount();
     try expect(cpu_count >= 1);
 }
 
src/ThreadPool.zig
@@ -60,7 +60,7 @@ pub fn init(self: *ThreadPool, allocator: *std.mem.Allocator) !void {
     if (std.builtin.single_threaded)
         return;
 
-    const worker_count = std.math.max(1, std.Thread.cpuCount() catch 1);
+    const worker_count = std.math.max(1, std.Thread.getCpuCount() catch 1);
     self.workers = try allocator.alloc(Worker, worker_count);
     errdefer allocator.free(self.workers);