Skip to content

make starts_on work with sequence senders through __subscribe - #2451

Open
alwaysprince05 wants to merge 2 commits into
NVIDIA:mainfrom
alwaysprince05:feat/seq-sndr-subscribe
Open

alwaysprince05 wants to merge 2 commits into
NVIDIA:mainfrom
alwaysprince05:feat/seq-sndr-subscribe

Conversation

@alwaysprince05

Copy link
Copy Markdown
Contributor

Step 2 from the plan in #2439, on top of #2443.

When the last sender of __seq::__sndr is a sequence sender, it now hooks STDEXEC::__subscribe: it runs the first sender, then subscribes the sequence with a receiver that forwards set_next. starts_on lowers to __sequence, so starts_on(sch, seq) now keeps the item types of seq and its items run on sch. Before this it was treated as a sequence of one item. Nothing in starts_on or sequence_senders.hpp names a specific algorithm.

Two small things in exec were needed since stdexec can't see exec:

  • exec::sequence_sender_tag now derives from a new STDEXEC::__sequence_sender_tag, so __seq::__sndr can tell its last sender is a sequence and use that tag itself.
  • get_item_types gets a generic hook: a sender can name __item_types_from_t<Self, Env...> as __mlist<Sender, SenderEnv...>, meaning its items are the items of Sender in SenderEnv. __seq::__sndr uses it for its last sender. Moving get_item_types itself into stdexec would make this go away, but that pulls in most of the item types machinery, so I left it out. Happy to change it if you'd rather do it another way.

Added tests in test/exec/sequence/test_starts_on_sequence.cpp (item types, items run on the scheduler, starts_on over iterate). test.exec and test.stdexec pass with Apple clang, gcc 14, and clang 16 + libc++; also checked g++-16 and STDEXEC_ENABLE_EXTRA_TYPE_CHECKING. clang-format 21.1.8 clean.

__seq::__sndr hooks STDEXEC::__subscribe when its last sender is a sequence
sender: it runs the first sender, then subscribes the sequence. starts_on
lowers to __sequence, so it now keeps the item types of a sequence child.
@copy-pr-bot

copy-pr-bot Bot commented Nov 12, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

Comment thread include/stdexec/__detail/__sequence.hpp Outdated
static constexpr auto __static_subscribe(_Self &&__self, _Receiver __rcvr)
noexcept(__nothrow_constructible_from<__subscribe_opstate_t<_Self, _Receiver>,
__copy_cvref_t<_Self, _Sender1>,
_Sender2,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

should this be __copy_cvref_t<_Self, _Sender2>?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, thanks. __sndr2_ is forwarded as __copy_cvref_t<_Self, _Sender2> into a by-value parameter, so the check should use that type. Fixed in 0f59cca, in both __static_subscribe and connect (it had the same pattern).

This branch has not been deployed

No deployments
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