ParallelLoop: make loop tasks cancellable to avoid hang on Teardown

SimpleParallelTask/LoopRangeTask never overrode Cancellable(), so a
ThreadManager::Teardown() racing with an in-flight parallel loop would
drop them without ever calling counter_->Count(), leaving anyone
blocked in WaitableCounter::Wait() stuck forever. Cancel() now counts
down the same as a normal completion.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L4QAoxV2KY7ek4PcZw3WvY
This commit is contained in:
Henrik RydgårdandClaude Sonnet 5 committed 2026-08-09 19:03:28 +02:00
1 parent dcf742edb4
commit 973a10473a
2 files changed
+20

No files matched your search

+10
View File
@@ -23,6 +23,16 @@ public:
counter_->Count();
}
// Cancellable so a Teardown() racing with an in-flight parallel loop still
// counts down the waiter's counter instead of leaving it blocked forever.
bool Cancellable() const override {
return true;
}
void Cancel() override {
counter_->Count();
}
std::function<void(int, int)> loop_;
WaitableCounter *counter_;