···11//
22-// In exercise 088, we learned that cancellation happens at
22+// In exercise 089, we learned that cancellation happens at
33// "cancellation points" — any Io function that can return
44// error.Canceled.
55//
···1111//
1212// const old = io.swapCancelProtection(.blocked);
1313// defer _ = io.swapCancelProtection(old);
1414-//
1414+1515// // In this block, NO Io function will return error.Canceled.
1616// // The cancel request is held until protection is restored.
1717//
···3636 const io = init.io;
37373838 var future = io.async(importantTask, .{io});
3939+ defer _ = future.cancel(io);
39404041 // Give the task time to start and enter its critical section.
4141- io.sleep(std.Io.Duration.fromMilliseconds(300), .awake) catch {};
4242+ io.sleep(std.Io.Duration.fromMilliseconds(200), .awake) catch {};
42434344 // Cancel while the task is in its protected section.
4445 const result = future.cancel(io);
···50515152 // Protect this section from cancellation.
5253 // What method swaps the cancel protection state?
5353- const old = io.???(. blocked);
5454+ const old = io.???(.blocked);
5455 defer _ = io.???(old);
55565657 // This sleep will NOT return error.Canceled even though
5758 // we get canceled during it — protection is active!
5858- io.sleep(std.Io.Duration.fromMilliseconds(600), .awake) catch |err| switch (err) {
5959+ io.sleep(std.Io.Duration.fromMilliseconds(300), .awake) catch |err| switch (err) {
5960 error.Canceled => {
6061 // This should never happen while protected!
6162 return "ERROR: canceled during critical section!";
+4-4
patches/patches/094_async10.patch
···11---- exercises/094_async10.zig 2026-04-03 14:25:16.600025924 +0200
22-+++ answers/094_async10.zig 2026-04-03 14:24:56.192615893 +0200
33-@@ -50,8 +50,8 @@
11+--- exercises/094_async10.zig 2026-04-06 19:36:59.873966580 +0200
22++++ answers/094_async10.zig 2026-04-06 19:37:12.416216872 +0200
33+@@ -51,8 +51,8 @@
4455 // Protect this section from cancellation.
66 // What method swaps the cancel protection state?
77-- const old = io.???(. blocked);
77+- const old = io.???(.blocked);
88- defer _ = io.???(old);
99+ const old = io.swapCancelProtection(.blocked);
1010+ defer _ = io.swapCancelProtection(old);