From 147ff302ecbc534af01004a016fc2c091cba8af4 Mon Sep 17 00:00:00 2001 From: Chris Boesch Date: Sat, 1 Nov 2025 15:46:31 +0100 Subject: [PATCH] fixed more changes due to new I/O API --- README.md | 3 ++- build.zig | 2 +- exercises/104_threading.zig | 6 +++--- patches/patches/104_threading.patch | 11 ++++++++--- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 5c930d2..bcf60db 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ the appropriate tag. The Zig language is under very active development. In order to be current, Ziglings tracks **development** builds of the Zig compiler rather than versioned **release** builds. The last -stable release was `0.15.1`, but Ziglings needs a dev build with +stable release was `0.15.2`, but Ziglings needs a dev build with pre-release version "0.16.0" and a build number at least as high as that shown in the example version check above. @@ -86,6 +86,7 @@ that if you update one, you may need to also update the other. ### Version Changes +* *2025-11-01* zig 0.16.0-dev.1204 - more changes due to new I/O API, see [#25592](https://github.com/ziglang/zig/pull/25592) * *2025-09-24* zig 0.16.0-dev.377 - Enable passing file content as args, see [#25228](https://github.com/ziglang/zig/pull/25228) * *2025-09-03* zig 0.16.0-dev.164 - changes in reader, see [#25077](https://github.com/ziglang/zig/pull/25077) * *2025-08-15* zig 0.15.0-dev.1519 - changes in array list, see [#24801](https://github.com/ziglang/zig/pull/24801) diff --git a/build.zig b/build.zig index 2a16899..bc0b23e 100644 --- a/build.zig +++ b/build.zig @@ -15,7 +15,7 @@ const print = std.debug.print; // 1) Getting Started // 2) Version Changes comptime { - const required_zig = "0.16.0-dev.377"; + const required_zig = "0.16.0-dev.1204"; const current_zig = builtin.zig_version; const min_zig = std.SemanticVersion.parse(required_zig) catch unreachable; if (current_zig.order(min_zig) == .lt) { diff --git a/exercises/104_threading.zig b/exercises/104_threading.zig index 638769f..d0a640b 100644 --- a/exercises/104_threading.zig +++ b/exercises/104_threading.zig @@ -106,7 +106,7 @@ pub fn main() !void { // After the threads have been started, // they run in parallel and we can still do some work in between. - std.Thread.sleep(1500 * std.time.ns_per_ms); + std.posix.nanosleep(1, 0); std.debug.print("Some weird stuff, after starting the threads.\n", .{}); } // After we have left the closed area, we wait until @@ -117,12 +117,12 @@ pub fn main() !void { // This function is started with every thread that we set up. // In our example, we pass the number of the thread as a parameter. fn thread_function(num: usize) !void { - std.Thread.sleep(200 * num * std.time.ns_per_ms); + std.posix.nanosleep(1 * num, 0); std.debug.print("thread {d}: {s}\n", .{ num, "started." }); // This timer simulates the work of the thread. const work_time = 3 * ((5 - num % 3) - 2); - std.Thread.sleep(work_time * std.time.ns_per_s); + std.posix.nanosleep(work_time, 0); std.debug.print("thread {d}: {s}\n", .{ num, "finished." }); } diff --git a/patches/patches/104_threading.patch b/patches/patches/104_threading.patch index 1ca46c1..bd02cc0 100644 --- a/patches/patches/104_threading.patch +++ b/patches/patches/104_threading.patch @@ -1,6 +1,6 @@ ---- exercises/104_threading.zig 2024-04-10 19:12:29.878856370 +0200 -+++ answers/104_threading.zig 2024-04-10 19:11:22.304265713 +0200 -@@ -97,12 +97,12 @@ +--- exercises/104_threading.zig 2025-11-01 15:37:31.299815135 +0100 ++++ answers/104_threading.zig 2025-11-01 15:39:28.774262735 +0100 +@@ -97,16 +97,16 @@ defer handle.join(); // Second thread @@ -15,3 +15,8 @@ // After the threads have been started, // they run in parallel and we can still do some work in between. +- std.posix.nanosleep(1, 0); ++ std.posix.nanosleep(4, 0); + std.debug.print("Some weird stuff, after starting the threads.\n", .{}); + } + // After we have left the closed area, we wait until