Merge pull request 'fixed more changes due to new I/O API' (#316) from new_io_2 into main

Reviewed-on: https://codeberg.org/ziglings/exercises/pulls/316
This commit is contained in:
Chris Boesch 2025-11-01 15:52:40 +01:00
commit 4c291f35d5
4 changed files with 14 additions and 8 deletions

View File

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

View File

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

View File

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

View File

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