Skip to content

Add range-based when_all overloads and consolidate internals#231

Merged
mvandeberg merged 1 commit intocppalliance:developfrom
mvandeberg:pr/205-when-all-range
Mar 12, 2026
Merged

Add range-based when_all overloads and consolidate internals#231
mvandeberg merged 1 commit intocppalliance:developfrom
mvandeberg:pr/205-when-all-range

Conversation

@mvandeberg
Copy link
Contributor

@mvandeberg mvandeberg commented Mar 12, 2026

Closes #205

Add when_all(Range&&) overloads for homogeneous non-void and void awaitable ranges, matching the existing when_any range API. Extract when_all_core and unify runner types to reduce internal duplication.

  • Add IoAwaitableRange concept to concept/io_awaitable.hpp (shared with when_any)
  • Add when_all_homogeneous_state, when_all_homogeneous_state, and when_all_homogeneous_launcher for range support
  • Extract when_all_core from duplicated state members
  • Unify when_all_runner and when_all_homogeneous_runner into single when_all_runner
  • Remove duplicate IoAwaitableRange definition from when_any.hpp
  • Add when_all_range_test suite (11 tests)

Summary by CodeRabbit

  • New Features

    • Extended when_all to support range-based collections of awaitables, enabling batch operations on vectors or ranges of async tasks.
    • Added specialized handling for void-result ranges.
  • Refactor

    • Improved internal state management architecture for better synchronization and lifecycle handling in concurrent operations.

…ance#205)

Add when_all(Range&&) overloads for homogeneous non-void and void
awaitable ranges, matching the existing when_any range API. Extract
when_all_core and unify runner types to reduce internal duplication.

- Add IoAwaitableRange concept to concept/io_awaitable.hpp (shared
  with when_any)
- Add when_all_homogeneous_state<T>, when_all_homogeneous_state<void>,
  and when_all_homogeneous_launcher<Range> for range support
- Extract when_all_core from duplicated state members
- Unify when_all_runner and when_all_homogeneous_runner into single
  when_all_runner<StateType>
- Remove duplicate IoAwaitableRange definition from when_any.hpp
- Add when_all_range_test suite (11 tests)
@coderabbitai
Copy link

coderabbitai bot commented Mar 12, 2026

📝 Walkthrough

Walkthrough

The PR introduces range-based overloads for when_all to enable parallel execution of dynamic collections of homogeneous tasks. It refactors internal state management using composition, introducing a shared when_all_core component, homogeneous state types for ranges, and moves the IoAwaitableRange concept to a central location while maintaining behavioral compatibility.

Changes

Cohort / File(s) Summary
Concept centralization
include/boost/capy/concept/io_awaitable.hpp
Adds <ranges> header and introduces IoAwaitableRange concept requiring input_range, sized_range, and IoAwaitable value type.
State and runner refactoring
include/boost/capy/when_all.hpp
Introduces when_all_core for shared synchronization state. Replaces monolithic when_all_state with composition-based design containing core, results tuple, and runner handles. Adds homogeneous variants (when_all_homogeneous_state<T> and specialization for void) for range-based execution with vector-based results storage.
Runner abstraction and launchers
include/boost/capy/when_all.hpp
Adds generic when_all_runner<StateType> template managing promise_type with updated await_suspend/final_suspend logic. Updates when_all_launcher to use core fields and adds new when_all_homogeneous_launcher for range-based two-phase launching to handle synchronous completion.
Public API expansion
include/boost/capy/when_all.hpp
Adds range-based when_all overloads: one returning task<vector<T>> for non-void ranges and one returning task<void> for void ranges. Introduces when_all_result_t alias and factory functions make_when_all_runner and make_when_all_homogeneous_runner.
Concept relocation
include/boost/capy/when_any.hpp
Removes IoAwaitableRange concept declaration (moved to central location in io_awaitable.hpp).

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related issues

Possibly related PRs

Poem

🐰 A rabbit hops through composition's door,
Where cores and runners dance once more.
Range by range, the tasks align,
In parallel rows, a grand design.
When all awaits with homogeneous grace,
Results flutter back to their rightful place. 🌈

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: adding range-based when_all overloads and consolidating internal state management with core separation.
Linked Issues check ✅ Passed The PR fully addresses issue #205 objectives: adds range-based when_all overloads, moves IoAwaitableRange concept to shared location, implements homogeneous state/launcher types, and preserves input order semantics.
Out of Scope Changes check ✅ Passed All changes are within scope: IoAwaitableRange addition/relocation, when_all_core extraction for state consolidation, homogeneous state/launcher/runner types, and range-based when_all overloads directly fulfill issue #205 requirements.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cppalliance-bot
Copy link

An automated preview of the documentation is available at https://231.capy.prtest3.cppalliance.org/index.html

If more commits are pushed to the pull request, the docs will rebuild at the same URL.

2026-03-12 18:16:57 UTC

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
include/boost/capy/concept/io_awaitable.hpp (1)

125-136: Concept documentation is minimal compared to IoAwaitable above.

The IoAwaitableRange concept definition is correct. However, the coding guidelines require comprehensive concept javadoc including @par Syntactic Requirements, @par Semantic Requirements, @par Conforming Signatures, @par Example, and @see sections. The existing IoAwaitable concept (lines 21-114) demonstrates the expected level of detail.

Consider expanding the documentation to match the project's established pattern, or at minimum adding an @par Example and @see cross-reference:

📝 Suggested documentation additions
 /** Concept for ranges of I/O awaitables.

     A range satisfies `IoAwaitableRange` if it is a sized input range
     whose value type satisfies `@ref` IoAwaitable.

     `@tparam` R The range type.
+
+    `@par` Syntactic Requirements
+
+    `@li` `std::ranges::input_range<R>` is satisfied
+    `@li` `std::ranges::sized_range<R>` is satisfied
+    `@li` `IoAwaitable<std::ranges::range_value_t<R>>` is satisfied
+
+    `@par` Example
+
+    `@code`
+    template<IoAwaitableRange R>
+    task<void> run_all(R&& awaitables)
+    {
+        co_await when_all(std::forward<R>(awaitables));
+    }
+    `@endcode`
+
+    `@see` IoAwaitable, when_all, when_any
 */

As per coding guidelines: "Concept javadoc should include @par Syntactic Requirements with bulleted @li list of every valid expression" and "Concept javadoc should include @par Example with a @code block."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@include/boost/capy/concept/io_awaitable.hpp` around lines 125 - 136, The
IoAwaitableRange concept lacks the comprehensive javadoc required by our
guidelines; update the comment block for template<typename R> concept
IoAwaitableRange to include `@par` Syntactic Requirements (enumerate valid
expressions using std::ranges::input_range, std::ranges::sized_range, and
IoAwaitable<std::ranges::range_value_t<R>>), `@par` Semantic Requirements
(expected runtime/complexity/ownership guarantees), `@par` Conforming Signatures
(signature of the concept and value_type relationship), an `@par` Example section
with a `@code` block showing a minimal type that satisfies IoAwaitableRange, and a
`@see` pointing to IoAwaitable to mirror the pattern used in the IoAwaitable
documentation; keep the concept definition intact (IoAwaitableRange) and follow
the same phrasing/style as the IoAwaitable comment above.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@include/boost/capy/concept/io_awaitable.hpp`:
- Around line 125-136: The IoAwaitableRange concept lacks the comprehensive
javadoc required by our guidelines; update the comment block for
template<typename R> concept IoAwaitableRange to include `@par` Syntactic
Requirements (enumerate valid expressions using std::ranges::input_range,
std::ranges::sized_range, and IoAwaitable<std::ranges::range_value_t<R>>), `@par`
Semantic Requirements (expected runtime/complexity/ownership guarantees), `@par`
Conforming Signatures (signature of the concept and value_type relationship), an
`@par` Example section with a `@code` block showing a minimal type that satisfies
IoAwaitableRange, and a `@see` pointing to IoAwaitable to mirror the pattern used
in the IoAwaitable documentation; keep the concept definition intact
(IoAwaitableRange) and follow the same phrasing/style as the IoAwaitable comment
above.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: dc554b09-891c-4012-843f-56634fdcac95

📥 Commits

Reviewing files that changed from the base of the PR and between ecdb076 and 1149f9c.

⛔ Files ignored due to path filters (1)
  • test/unit/when_all.cpp is excluded by !**/test/**
📒 Files selected for processing (3)
  • include/boost/capy/concept/io_awaitable.hpp
  • include/boost/capy/when_all.hpp
  • include/boost/capy/when_any.hpp
💤 Files with no reviewable changes (1)
  • include/boost/capy/when_any.hpp

@cppalliance-bot
Copy link

GCOVR code coverage report https://231.capy.prtest3.cppalliance.org/gcovr/index.html
LCOV code coverage report https://231.capy.prtest3.cppalliance.org/genhtml/index.html
Coverage Diff Report https://231.capy.prtest3.cppalliance.org/diff-report/index.html

Build time: 2026-03-12 18:33:54 UTC

@codecov
Copy link

codecov bot commented Mar 12, 2026

Codecov Report

❌ Patch coverage is 97.46835% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.48%. Comparing base (18c30d2) to head (1149f9c).
⚠️ Report is 2 commits behind head on develop.

Files with missing lines Patch % Lines
include/boost/capy/when_all.hpp 97.46% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #231      +/-   ##
===========================================
+ Coverage    92.38%   92.48%   +0.09%     
===========================================
  Files          162      162              
  Lines         8854     8958     +104     
===========================================
+ Hits          8180     8285     +105     
+ Misses         674      673       -1     
Flag Coverage Δ
linux 92.44% <ø> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
include/boost/capy/when_any.hpp 99.31% <ø> (ø)
include/boost/capy/when_all.hpp 98.64% <97.46%> (+0.68%) ⬆️

... and 7 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 18c30d2...1149f9c. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mvandeberg mvandeberg merged commit 19821af into cppalliance:develop Mar 12, 2026
38 checks passed
@mvandeberg mvandeberg deleted the pr/205-when-all-range branch March 12, 2026 19:02
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.

Add range-based overload for when_all

2 participants