my ziglings
0

Configure Feed

Select the types of activity you want to include in your feed.

095_quiz_async: Add missing Bug 4

Tom (Apr 13, 2026, 7:11 PM -0700) b8a639e7 b9cbe199

+10 -11
+2 -3
exercises/095_quiz_async.zig
··· 97 97 // there's no more data coming. 98 98 queue.close(io); 99 99 100 - // Wait for the collector to drain the remaining queue. 101 - _ = collector_future.await(io); 102 - // _ = collector_future.???(io); 100 + // Bug 4: How do we wait for the collector to drain the remaining queue? 101 + _ = collector_future.???(io); 103 102 104 103 // Now write the garden report. This is critical — it must 105 104 // NOT be interrupted, even if something tries to cancel us!
+8 -8
patches/patches/095_quiz_async.patch
··· 1 - --- exercises/095_quiz_async.zig 2026-04-06 19:55:17.111817364 +0200 2 - +++ answers/095_quiz_async.zig 2026-04-06 19:56:16.063974543 +0200 1 + --- exercises/095_quiz_async.zig 2026-04-13 19:11:04.173440326 -0700 2 + +++ answers/095_quiz_async.zig 2026-04-13 19:10:31.618592222 -0700 3 3 @@ -51,7 +51,7 @@ 4 4 fn addReading(self: *GardenWeather, io: std.Io, reading: Reading) void { 5 5 // Bug 1: The collector needs to lock before modifying ··· 18 18 defer _ = collector_future.cancel(io); 19 19 20 20 // Sensor group: the sensors can use async — they just need 21 - @@ -91,7 +91,7 @@ 21 + @@ -91,22 +91,22 @@ 22 22 23 23 // Bug 3: Wait for ALL sensors to finish sending their readings. 24 24 // What Group method blocks until all tasks complete? ··· 27 27 28 28 // All sensors done — close the queue so the collector knows 29 29 // there's no more data coming. 30 - @@ -99,15 +99,14 @@ 30 + queue.close(io); 31 31 32 - // Wait for the collector to drain the remaining queue. 33 - _ = collector_future.await(io); 34 - - // _ = collector_future.???(io); 32 + // Bug 4: How do we wait for the collector to drain the remaining queue? 33 + - _ = collector_future.???(io); 34 + + _ = collector_future.await(io); 35 35 36 36 // Now write the garden report. This is critical — it must 37 37 // NOT be interrupted, even if something tries to cancel us! ··· 45 45 46 46 printGardenReport(&weather); 47 47 } 48 - @@ -129,7 +128,7 @@ 48 + @@ -128,7 +128,7 @@ 49 49 50 50 // Bug 6: Send the reading into the queue. 51 51 // What Queue method sends a single element?