···3333// Let's try a slightly simplified example from signal processing:
3434// Suppose we're looking for the beginning of a signal above the noise
3535// level. To do this, we compare each entry from beginning to end with
3636-// the threshold.To speed things up a bit, we split the signal into
3636+// the threshold. To speed things up a bit, we split the signal into
3737// two halves and have two parallel workers search for them.
3838// Who finds the beginning first "wins" and thus ends the other one.
3939//
···6161 var queue = Io.Queue(SearchResult).init(&buf);
62626363 // Launch two workers, each searching half the array.
6464- var f1 = ???(searchRange, .{ data[0..mid], target, 0, 0, &queue, io });
6464+ // Remember, we want them to be guaranteed separate units of concurrency.
6565+ var f1 = ???(searchThreshold, .{ io, data[0..mid], threshold, 0, 0, &queue });
6566 defer _ = f1.cancel(io);
66676767- var f2 = ???(searchRange, .{ data[mid..], target, mid, 1, &queue, io });
6868+ var f2 = ???(searchThreshold, .{ io, data[mid..], threshold, mid, 1, &queue });
6869 defer _ = f2.cancel(io);
69707071 // Wait for the first result.
···8788 // all workers would continue until the end.
8889 io.sleep(Io.Duration.fromMilliseconds(1), .awake) catch return;
89909090- // To test this, you can view the work of the workers
9191+ // To test this, you can uncomment this to view the work of the workers
9192 // and then comment out the pause.
9293 // print("id: {} - val: {}\n", .{ worker_id, val });
9394···100101 }
101102 }
102103}
103103-
+6-11
patches/patches/093_async9.patch
···11---- exercises/093_async9.zig 2026-04-14 09:50:05.694073287 +0200
22-+++ answers/093_async9.zig 2026-04-14 09:49:58.604934765 +0200
33-@@ -61,10 +61,10 @@
44- var queue = Io.Queue(SearchResult).init(&buf);
11+--- exercises/093_async9.zig 2026-04-14 08:32:33.014583120 -0700
22++++ answers/093_async9.zig 2026-04-14 08:32:24.459647047 -0700
33+@@ -62,10 +62,10 @@
5465 // Launch two workers, each searching half the array.
77-- var f1 = ???(searchRange, .{ data[0..mid], target, 0, 0, &queue, io });
66+ // Remember, we want them to be guaranteed separate units of concurrency.
77+- var f1 = ???(searchThreshold, .{ io, data[0..mid], threshold, 0, 0, &queue });
88+ var f1 = try io.concurrent(searchThreshold, .{ io, data[0..mid], threshold, 0, 0, &queue });
99 defer _ = f1.cancel(io);
10101111-- var f2 = ???(searchRange, .{ data[mid..], target, mid, 1, &queue, io });
1111+- var f2 = ???(searchThreshold, .{ io, data[mid..], threshold, mid, 1, &queue });
1212+ var f2 = try io.concurrent(searchThreshold, .{ io, data[mid..], threshold, mid, 1, &queue });
1313 defer _ = f2.cancel(io);
14141515 // Wait for the first result.
1616-@@ -100,4 +100,3 @@
1717- }
1818- }
1919- }
2020--