std.Thread.getCpuCount(): fix usages

This commit is contained in:
kprotty
2021-06-19 21:50:34 -05:00
parent 0a1def7833
commit 3a276be135
3 changed files with 4 additions and 4 deletions

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);