···5252 state.mutex.??? catch return;
5353 defer state.mutex.unlock(); // <-- what's missing here?
54545555+ // Sleep to give the other tasks a chance to run in the meantime.
5656+ // We do this here only to make nondeterminism more visible.
5757+ io.sleep(std.Io.Duration.fromMilliseconds(1), .awake) catch {};
5858+5959+ // What happens if you neglect to lock the mutex?
6060+5561 state.counter += 1;
5662 }
5763}
+4-4
patches/patches/091_async7.patch
···11---- exercises/091_async7.zig 2026-04-02 10:50:08.142508099 +0200
22-+++ answers/091_async7.zig 2026-04-02 10:49:59.629341593 +0200
11+--- exercises/091_async7.zig 2026-04-18 23:30:40.963951835 +0200
22++++ answers/091_async7.zig 2026-04-18 23:33:47.313340585 +0200
33@@ -49,8 +49,8 @@
44 for (0..times) |_| {
55 // Acquire the lock before modifying shared state.
···99+ state.mutex.lock(io) catch return;
1010+ defer state.mutex.unlock(io);
11111212- state.counter += 1;
1313- }
1212+ // Sleep to give the other tasks a chance to run in the meantime.
1313+ // We do this here only to make nondeterminism more visible.