Skip to content

Add public type aliases for detail types in when_any/when_all APIs#203

Open
mvandeberg wants to merge 1 commit intocppalliance:developfrom
mvandeberg:pr/160-api-cleanup
Open

Add public type aliases for detail types in when_any/when_all APIs#203
mvandeberg wants to merge 1 commit intocppalliance:developfrom
mvandeberg:pr/160-api-cleanup

Conversation

@mvandeberg
Copy link
Contributor

@mvandeberg mvandeberg commented Mar 4, 2026

Addresses #160. Public function signatures referenced detail:: types that users cannot name without reaching into the detail namespace. Add awaitable_result_type, when_any_result_type, and when_all_result_type as public aliases, and update all when_any and when_all signatures to use them. Simplify when_any_variant_t and when_any_state to use a flat parameter pack instead of requiring the first type separately.

Summary by CodeRabbit

  • New Features

    • Made awaitable_result_t publicly available for direct use.
    • Added non-void tuple utility to produce void or compact tuples for multi-awaitable results.
  • Refactor

    • Simplified when_any to a single variadic overload returning a variant of awaitable results.
    • Streamlined when_all to return void when all awaitables are void and a concise tuple otherwise.
  • Documentation

    • Updated docs to clarify new public types and when_all/when_any behavior.

@coderabbitai
Copy link

coderabbitai bot commented Mar 4, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 449422eb-9cdb-4064-9060-3dbbc4a166e2

📥 Commits

Reviewing files that changed from the base of the PR and between 542f0b2 and 2281eb3.

⛔ Files ignored due to path filters (1)
  • test/unit/when_all.cpp is excluded by !**/test/**
📒 Files selected for processing (4)
  • example/async-mutex/async_mutex.cpp
  • 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)
  • example/async-mutex/async_mutex.cpp

📝 Walkthrough

Walkthrough

Exposes awaitable_result_t publicly, adds non_void_tuple_t and replaces when_all_result_t, simplifies when_any to a single variadic API returning a positional std::variant over awaitable results, and removes an unused local constexpr in an example.

Changes

Cohort / File(s) Summary
Type Alias Exposure
include/boost/capy/concept/io_awaitable.hpp
Moved awaitable_result_t from detail into boost::capy as a documented public alias: template<typename A> using awaitable_result_t = decltype(std::declval<std::decay_t<A>&>().await_resume());.
when_all Result Type Refactor
include/boost/capy/when_all.hpp
Removed when_all_result_t; added public non_void_tuple_t<Ts...> that filters out void (yields void if all are void); updated when_all return and internal aliases to use non_void_tuple_t<awaitable_result_t<As>...>.
when_any API Simplification
include/boost/capy/when_any.hpp
Replaced when_any(A0, As...) with single variadic when_any(As...) (requires at least one); public return type changed to task<std::variant<void_to_monostate_t<awaitable_result_t<As>>...>>; removed detail::when_any_variant_t and updated state/template/task_count/aliases accordingly.
Example Cleanup
example/async-mutex/async_mutex.cpp
Removed an unused local constexpr int num_workers = 6; no runtime behavior changes (workers still referenced directly).

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related issues

Possibly related PRs

Poem

🐰 I hopped through headers late at night,

Pulled awaitable_result_t into the light,
when_any flattened to a single spread,
when_all trims voids to tuck them bed,
A rabbit's tidy change — all types sleep tight.

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add public type aliases for detail types in when_any/when_all APIs' clearly and directly summarizes the main change: exposing previously internal detail types through public aliases.

✏️ 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

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

cppalliance-bot commented Mar 4, 2026

An automated preview of the documentation is available at https://203.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-04 21:41:43 UTC

@cppalliance-bot
Copy link

cppalliance-bot commented Mar 4, 2026

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

Build time: 2026-03-04 21:55:51 UTC

@mvandeberg mvandeberg force-pushed the pr/160-api-cleanup branch from 9ad460b to fa28e43 Compare March 4, 2026 19:53
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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@include/boost/capy/when_any.hpp`:
- Around line 562-563: Remove the Javadoc `@tparam As` entry for the variadic
template pack and leave the `@param as` description intact; specifically, in the
when_any async variadic overload in when_any.hpp delete the `@tparam As
Awaitable types (each must satisfy IoAwaitable).` line and, if needed, move any
concept requirement text into the main description (not as a `@tparam`) so the
variadic pack As is not documented with a `@tparam` tag.
- Around line 578-580: The variadic when_any template currently permits zero
arguments, yielding an invalid empty std::variant; change the template signature
to require at least one awaitable (e.g., replace template<IoAwaitable... As>
with template<IoAwaitable A0, IoAwaitable... As> and adjust the return type to
use A0, As... with void_to_monostate_t<awaitable_result_t<...>> so an empty pack
is impossible), and update occurrences referencing when_any accordingly; also
remove the `@tparam` As line from the function javadoc to follow the guideline
that variadic template parameters should not be documented.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 249b7904-5bbf-4f1c-a78a-5183ea0e790e

📥 Commits

Reviewing files that changed from the base of the PR and between 2d4c01f and fa28e43.

⛔ Files ignored due to path filters (1)
  • test/unit/when_all.cpp is excluded by !**/test/**
📒 Files selected for processing (4)
  • example/async-mutex/async_mutex.cpp
  • 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)
  • example/async-mutex/async_mutex.cpp

@mvandeberg mvandeberg force-pushed the pr/160-api-cleanup branch from fa28e43 to b9ea7eb Compare March 4, 2026 20:25
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.

♻️ Duplicate comments (1)
include/boost/capy/when_any.hpp (1)

562-563: ⚠️ Potential issue | 🟡 Minor

Remove variadic @tparam As from this async overload docblock.

Line 562 still documents variadic template args with @tparam, which violates the async javadoc rule for variadic packs.

📝 Suggested doc edit
-    `@tparam` As Awaitable types (each must satisfy IoAwaitable).
     `@param` as Awaitables to race concurrently.

As per coding guidelines: "Document tparam in async/awaitable function javadoc for non-variadic template parameters, stating concept requirements and not documenting variadic Args...".

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

In `@include/boost/capy/when_any.hpp` around lines 562 - 563, Remove the variadic
template `@tparam` As entry from the async overload docblock in
include/boost/capy/when_any.hpp: locate the async overload's comment block (the
one that currently lists "@tparam As Awaitable types (each must satisfy
IoAwaitable)." above "@param as Awaitables to race concurrently.") and delete
the `@tparam` As line so the docblock no longer documents a variadic template
parameter; keep the `@param` as line and ensure only non-variadic template
parameters are documented elsewhere per the async/awaitable documentation rules.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@include/boost/capy/when_any.hpp`:
- Around line 562-563: Remove the variadic template `@tparam` As entry from the
async overload docblock in include/boost/capy/when_any.hpp: locate the async
overload's comment block (the one that currently lists "@tparam As Awaitable
types (each must satisfy IoAwaitable)." above "@param as Awaitables to race
concurrently.") and delete the `@tparam` As line so the docblock no longer
documents a variadic template parameter; keep the `@param` as line and ensure only
non-variadic template parameters are documented elsewhere per the
async/awaitable documentation rules.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 55af6c93-6d31-4564-9375-dd1b7badcce8

📥 Commits

Reviewing files that changed from the base of the PR and between fa28e43 and b9ea7eb.

⛔ Files ignored due to path filters (1)
  • test/unit/when_all.cpp is excluded by !**/test/**
📒 Files selected for processing (4)
  • example/async-mutex/async_mutex.cpp
  • 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)
  • example/async-mutex/async_mutex.cpp

@codecov
Copy link

codecov bot commented Mar 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.89%. Comparing base (df92ffb) to head (2281eb3).
⚠️ Report is 13 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #203      +/-   ##
===========================================
+ Coverage    91.71%   91.89%   +0.18%     
===========================================
  Files           76       76              
  Lines         4488     4504      +16     
===========================================
+ Hits          4116     4139      +23     
+ Misses         372      365       -7     
Files with missing lines Coverage Δ
include/boost/capy/when_all.hpp 97.95% <ø> (ø)
include/boost/capy/when_any.hpp 99.31% <ø> (+<0.01%) ⬆️

... and 6 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 7715a31...2281eb3. 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 force-pushed the pr/160-api-cleanup branch from b9ea7eb to 542f0b2 Compare March 4, 2026 21:31
Type traits used in when_any/when_all return types were in detail::,
forcing users to reach into the detail namespace to name them.
Move these traits to the public namespace with descriptive names
so signatures are self-documenting:

- awaitable_result_t<A>: the return type of co_await on an awaitable
- void_to_monostate_t<T>: maps void to std::monostate for variant storage
- non_void_tuple_t<Ts...>: a tuple with void types filtered out

when_any now returns std::variant<void_to_monostate_t<...>...> directly
in its signature instead of hiding behind an alias. when_all uses
non_void_tuple_t in its signature. Both are immediately readable
without chasing type aliases.

Also simplify when_any_state to use a flat parameter pack (Ts...)
instead of requiring the first type separately (T0, Ts...).
@mvandeberg mvandeberg force-pushed the pr/160-api-cleanup branch from 542f0b2 to 2281eb3 Compare March 4, 2026 21:35
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.

♻️ Duplicate comments (1)
include/boost/capy/when_any.hpp (1)

562-563: ⚠️ Potential issue | 🟡 Minor

Remove variadic @tparam As from this async overload javadoc.

Line 562 still documents a variadic template pack with @tparam, which conflicts with the repo async-doc rule.

📝 Suggested doc fix
-    `@tparam` As Awaitable types (each must satisfy IoAwaitable; at least one required).
     `@param` as Awaitables to race concurrently (must not be empty).
As per coding guidelines: "Document tparam in async/awaitable function javadoc for non-variadic template parameters, stating concept requirements and not documenting variadic Args...".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@include/boost/capy/when_any.hpp` around lines 562 - 563, The javadoc for the
async overload of when_any in include/boost/capy/when_any.hpp incorrectly
documents a variadic template pack with "@tparam As"; remove that variadic
"@tparam As" line from the async/awaitable overload's comment and instead ensure
the comment states the requirement in prose (e.g., "Awaitables to race
concurrently (must not be empty); each must satisfy IoAwaitable") next to the
"@param as" description for the when_any async overload so it conforms to the
repo async-doc rule.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@include/boost/capy/when_any.hpp`:
- Around line 562-563: The javadoc for the async overload of when_any in
include/boost/capy/when_any.hpp incorrectly documents a variadic template pack
with "@tparam As"; remove that variadic "@tparam As" line from the
async/awaitable overload's comment and instead ensure the comment states the
requirement in prose (e.g., "Awaitables to race concurrently (must not be
empty); each must satisfy IoAwaitable") next to the "@param as" description for
the when_any async overload so it conforms to the repo async-doc rule.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5527a05e-752d-450a-93ed-fe3112e1413d

📥 Commits

Reviewing files that changed from the base of the PR and between b9ea7eb and 542f0b2.

⛔ Files ignored due to path filters (1)
  • test/unit/when_all.cpp is excluded by !**/test/**
📒 Files selected for processing (4)
  • example/async-mutex/async_mutex.cpp
  • 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)
  • example/async-mutex/async_mutex.cpp

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