diff options
| author | Chris Boesch <chrboesch@noreply.codeberg.org> | 2026-04-14 22:23:33 +0200 |
|---|---|---|
| committer | Chris Boesch <chrboesch@noreply.codeberg.org> | 2026-04-14 22:23:33 +0200 |
| commit | d4a3bad19ce163276e8373ac460bc40a33241067 (patch) | |
| tree | b459733e9e77feacfc943f3a5c5ffc489ce11a06 | |
| parent | 3f11ad125367b0ed2fd21c776cef061695174898 (diff) | |
| parent | e412619d88ee9deea9bfffe3bab57b6608faa828 (diff) | |
fixed merge conflict
| -rw-r--r-- | exercises/093_async9.zig | 12 | ||||
| -rw-r--r-- | patches/patches/093_async9.patch | 6 |
2 files changed, 12 insertions, 6 deletions
diff --git a/exercises/093_async9.zig b/exercises/093_async9.zig index 741462d..d4edd7b 100644 --- a/exercises/093_async9.zig +++ b/exercises/093_async9.zig @@ -45,8 +45,9 @@ const Io = std.Io; const print = std.debug.print; const SearchResult = struct { - worker_id: u8, - index: usize, + found: bool, + worker_id: u8 = 0, + index: usize = 0, }; pub fn main(init: std.process.Init) !void { @@ -71,7 +72,8 @@ pub fn main(init: std.process.Init) !void { // Wait for the first result. const result = try queue.getOne(io); - print("Worker {} found signal start over threshold at index {}!\n", .{ result.worker_id, result.index }); + if (result.found) + print("Worker {} found signal start over threshold at index {}!\n", .{ result.worker_id, result.index }); } fn searchThreshold( @@ -94,10 +96,14 @@ fn searchThreshold( if (val >= threshold) { queue.putOne(io, .{ + .found = true, .worker_id = worker_id, .index = base_offset + i, }) catch return; return; } } + + // Nothing found + queue.putOneUncancelable(io, .{ .found = false }) catch return; } diff --git a/patches/patches/093_async9.patch b/patches/patches/093_async9.patch index c8cc714..4aa54a1 100644 --- a/patches/patches/093_async9.patch +++ b/patches/patches/093_async9.patch @@ -1,6 +1,6 @@ ---- exercises/093_async9.zig 2026-04-14 08:32:33.014583120 -0700 -+++ answers/093_async9.zig 2026-04-14 08:32:24.459647047 -0700 -@@ -62,10 +62,10 @@ +--- exercises/093_async9.zig 2026-04-14 22:20:23.519107582 +0200 ++++ answers/093_async9.zig 2026-04-14 22:06:30.606912044 +0200 +@@ -63,10 +63,10 @@ // Launch two workers, each searching half the array. // Remember, we want them to be guaranteed separate units of concurrency. |
