mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
fix logic bug in groupAsync
This commit is contained in:
parent
b80e43903f
commit
c199124a84
1 changed files with 4 additions and 4 deletions
|
|
@ -695,10 +695,6 @@ fn groupAsync(
|
||||||
|
|
||||||
t.mutex.lock();
|
t.mutex.lock();
|
||||||
|
|
||||||
// Append to the group linked list inside the mutex to make `Io.Group.async` thread-safe.
|
|
||||||
gc.node = .{ .next = @ptrCast(@alignCast(group.token)) };
|
|
||||||
group.token = &gc.node;
|
|
||||||
|
|
||||||
if (t.available_thread_count == 0) {
|
if (t.available_thread_count == 0) {
|
||||||
if (t.cpu_count != 0 and t.threads.items.len >= t.cpu_count) {
|
if (t.cpu_count != 0 and t.threads.items.len >= t.cpu_count) {
|
||||||
t.mutex.unlock();
|
t.mutex.unlock();
|
||||||
|
|
@ -727,6 +723,10 @@ fn groupAsync(
|
||||||
t.available_thread_count -= 1;
|
t.available_thread_count -= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Append to the group linked list inside the mutex to make `Io.Group.async` thread-safe.
|
||||||
|
gc.node = .{ .next = @ptrCast(@alignCast(group.token)) };
|
||||||
|
group.token = &gc.node;
|
||||||
|
|
||||||
t.run_queue.prepend(&gc.closure.node);
|
t.run_queue.prepend(&gc.closure.node);
|
||||||
|
|
||||||
// This needs to be done before unlocking the mutex to avoid a race with
|
// This needs to be done before unlocking the mutex to avoid a race with
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue