handle ranged parallel awaiter with empty awaiters#60
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates ranged parallel awaiters to correctly handle empty awaiter ranges, preventing hangs and defining behavior for when_all/when_any on empty inputs.
Changes:
- Make ranged parallel awaiters complete immediately (
await_ready() == true) when the input range is empty. - Make ranged
when_anyextraction use bounds-checked access to produce a defined exception on empty input. - Add tests covering
when_allandwhen_anywith empty ranges.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/test_awaiter_operations.cpp | Adds test cases for when_all/when_any with empty ranges (immediate completion vs. exception). |
| include/condy/finish_handles.hpp | Uses order.at(0) to define std::out_of_range behavior for empty ranged when_any. |
| include/condy/awaiters.hpp | Treats empty ranged awaiter collections as immediately-ready to avoid deadlock/hang. |
Comments suppressed due to low confidence (1)
include/condy/finish_handles.hpp:316
- The comment suggests it's the caller's responsibility to ensure the range is non-empty, but the current behavior (and the new test) relies on
extract_result()throwingstd::out_of_rangefor an empty range. Please update this comment to match the intended API contract (e.g., explicitly document that empty input throws), or handle the empty case explicitly in a way that aligns with the publicwhen_any(range)semantics.
// May throw out_of_range if the range is empty, but it's the caller's
// responsibility to ensure that.
auto idx = order.at(0);
return std::make_pair(idx, std::move(results[idx]));
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
fa4b76c to
cd1bd17
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.