authorgravatar for kappaloris@gmail.comLoris Cro <kappaloris@gmail.com> 2025-11-07 13:33:45+01:00
committergravatar for kappaloris@gmail.comLoris Cro <kappaloris@gmail.com> 2025-11-07 13:33:45+01:00
logc199124a84f3c4b8d1eabb10620ae5be7d0275f9
treec1628466f9bbe5a4ce49cc21c8f8679c80e36159
parentb80e43903fdbf28c6383236a618d27b749717f56

fix logic bug in groupAsync


1 files changed, 4 insertions(+), 4 deletions(-)

lib/std/Io/Threaded.zig+4-4
......@@ -695,10 +695,6 @@ fn groupAsync(
695695
696696 t.mutex.lock();
697697
698 // Append to the group linked list inside the mutex to make `Io.Group.async` thread-safe.
699 gc.node = .{ .next = @ptrCast(@alignCast(group.token)) };
700 group.token = &gc.node;
701
702698 if (t.available_thread_count == 0) {
703699 if (t.cpu_count != 0 and t.threads.items.len >= t.cpu_count) {
704700 t.mutex.unlock();
......@@ -727,6 +723,10 @@ fn groupAsync(
727723 t.available_thread_count -= 1;
728724 }
729725
726 // Append to the group linked list inside the mutex to make `Io.Group.async` thread-safe.
727 gc.node = .{ .next = @ptrCast(@alignCast(group.token)) };
728 group.token = &gc.node;
729
730730 t.run_queue.prepend(&gc.closure.node);
731731
732732 // This needs to be done before unlocking the mutex to avoid a race with