Skip to content

handle ranged parallel awaiter with empty awaiters#60

Merged
wokron merged 1 commit into
masterfrom
empty-parallel-awaiter
Mar 1, 2026
Merged

handle ranged parallel awaiter with empty awaiters#60
wokron merged 1 commit into
masterfrom
empty-parallel-awaiter

Conversation

@wokron
Copy link
Copy Markdown
Member

@wokron wokron commented Feb 28, 2026

No description provided.

@wokron wokron changed the title Handle ranged parallel awaiter with empty awaiters handle ranged parallel awaiter with empty awaiters Feb 28, 2026
@wokron wokron requested a review from Copilot March 1, 2026 05:01
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_any extraction use bounds-checked access to produce a defined exception on empty input.
  • Add tests covering when_all and when_any with 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() throwing std::out_of_range for 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 public when_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.

@wokron wokron force-pushed the empty-parallel-awaiter branch from fa4b76c to cd1bd17 Compare March 1, 2026 05:17
@wokron wokron merged commit f8cf440 into master Mar 1, 2026
11 checks passed
@wokron wokron deleted the empty-parallel-awaiter branch March 1, 2026 06:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants