fn cancelThreads(g: Group, t: *Threaded) bool 579
580
581
582
583
584
585
586
587
588 fn cancelThreads(g: Group, t: *Threaded) bool {
var any_blocked = false;
var it = t.worker_threads.load(.acquire); // acquire `Thread` values
while (it) |thread| : (it = thread.next) {
// This non-mutating RMW exists for ordering reasons: see comment in `Group.Task.start` for reasons.
_ = thread.status.fetchOr(.{ .cancelation = @fromBackingInt(@intCast(0)), .awaitable = .null }, .release);
if (thread.cancelAwaitable(.fromGroup(g.ptr))) any_blocked = true;
}
return any_blocked;
}
Assumes the caller has already atomically updated the group status to indicate cancelation, and notifies any already-running threads of this cancelation.