authorgravatar for kbutcher6200@gmail.comkprotty <kbutcher6200@gmail.com> 2021-06-19 21:50:34-05:00
committergravatar for kbutcher6200@gmail.comkprotty <kbutcher6200@gmail.com> 2021-06-30 21:48:59-05:00
log3a276be1355fe304c177bcc13a7896122801e5f2
treebe3cb9210d4cb152403ca031f4565ed973fe086b
parent0a1def7833882249563358f262e2210beb77492a

std.Thread.getCpuCount(): fix usages


3 files changed, 4 insertions(+), 4 deletions(-)

lib/std/event/loop.zig+2-2
...@@ -137,7 +137,7 @@ pub const Loop = struct {...@@ -137,7 +137,7 @@ pub const Loop = struct {
137 }137 }
138138
139 /// After initialization, call run().139 /// After initialization, call run().
140 /// This is the same as `initThreadPool` using `Thread.cpuCount` to determine the thread140 /// This is the same as `initThreadPool` using `Thread.getCpuCount` to determine the thread
141 /// pool size.141 /// pool size.
142 /// TODO copy elision / named return values so that the threads referencing *Loop142 /// TODO copy elision / named return values so that the threads referencing *Loop
143 /// have the correct pointer value.143 /// have the correct pointer value.
...@@ -145,7 +145,7 @@ pub const Loop = struct {...@@ -145,7 +145,7 @@ pub const Loop = struct {
145 pub fn initMultiThreaded(self: *Loop) !void {145 pub fn initMultiThreaded(self: *Loop) !void {
146 if (builtin.single_threaded)146 if (builtin.single_threaded)
147 @compileError("initMultiThreaded unavailable when building in single-threaded mode");147 @compileError("initMultiThreaded unavailable when building in single-threaded mode");
148 const core_count = try Thread.cpuCount();148 const core_count = try Thread.getCpuCount();
149 return self.initThreadPool(core_count);149 return self.initThreadPool(core_count);
150 }150 }
151151
lib/std/os/test.zig+1-1
...@@ -364,7 +364,7 @@ fn start2(ctx: *i32) u8 {...@@ -364,7 +364,7 @@ fn start2(ctx: *i32) u8 {
364test "cpu count" {364test "cpu count" {
365 if (native_os == .wasi) return error.SkipZigTest;365 if (native_os == .wasi) return error.SkipZigTest;
366366
367 const cpu_count = try Thread.cpuCount();367 const cpu_count = try Thread.getCpuCount();
368 try expect(cpu_count >= 1);368 try expect(cpu_count >= 1);
369}369}
370370
src/ThreadPool.zig+1-1
...@@ -60,7 +60,7 @@ pub fn init(self: *ThreadPool, allocator: *std.mem.Allocator) !void {...@@ -60,7 +60,7 @@ pub fn init(self: *ThreadPool, allocator: *std.mem.Allocator) !void {
60 if (std.builtin.single_threaded)60 if (std.builtin.single_threaded)
61 return;61 return;
6262
63 const worker_count = std.math.max(1, std.Thread.cpuCount() catch 1);63 const worker_count = std.math.max(1, std.Thread.getCpuCount() catch 1);
64 self.workers = try allocator.alloc(Worker, worker_count);64 self.workers = try allocator.alloc(Worker, worker_count);
65 errdefer allocator.free(self.workers);65 errdefer allocator.free(self.workers);
6666