Skip to content

Fix __receiver_proxy_base start_scheduler_t query. - #2225

Open
yulin25 wants to merge 2 commits into
NVIDIA:mainfrom
yulin25:receiver-proxy-start-sched-query
Open

Fix __receiver_proxy_base start_scheduler_t query.#2225
yulin25 wants to merge 2 commits into
NVIDIA:mainfrom
yulin25:receiver-proxy-start-sched-query

Conversation

@yulin25

@yulin25 yulin25 commented Aug 23, 2026

Copy link
Copy Markdown

Current behaviour

When start scheduler is queried, __receiver_proxy_base does:

  1. If the requested scheduler type is not task_scheduler, we just declare
    that there is no start scheduler, and the query returns nullopt.
  2. Otherwise, the user is explicitly querying a start scheduler as task_scheduler.
    1. If there do exists a start scheduler, we give you the task_scheduler constructed
      from the start scheduler. And if the constructor throws, std::terminate() is automatically invoked as querying is noexcept.
    2. Otherwise, there is no start scheduler, but we still give you a task_scheduler created with inline_scheduler. Again, std::terminate() on exception.

There is one problem I encountered currently

This code does not compile:

namespace ex = STDEXEC;
auto sched = ex::get_parallel_scheduler();
ex::sync_wait(ex::starts_on(sched,ex::starts_on(sched,ex::just())));

That is parallel_scheduler being the start scheduler
which does not satisfies task_scheduler constructor's constraints, caused compilation failure.

task_scheduler is not named any_scheduler, which means some scheduler types can not be used to construct a task_scheduler, but 2.1 does not check that.

Fixes in this PR

  1. If the start scheduler can not be used to construct a task_scheduler, and the user is explicitly requesting
    a task_scheduler, then there is no such start scheduler of the requested type.

  2. According to the specification of receiver_proxy::try_query:

    Returns: Let env be the environment of the receiver represented by *this. If
    - Query is not a member of an implementation-defined set of supported queries; or
    - P is not a member of an implementation-defined set of supported result types for Query; or
    - the expression q(env) is not well-formed,
    then returns nullopt. Otherwise, if q(env) has type cv P, then returns q(env). Otherwise, returns an implementation-defined value of type optional<P>.

    1. Current implementation returns inline_scheduler when q(env)is not well-formed, which should be nullopt according to the standard.

    2. When the start scheduler's type is not task_scheduler, return an implementation-defined value of type optional<task_scheduler>:

      • If constructible as task_scheduler, return constructed task_scheduler.
      • Otherwise, return nullopt.

* Return task_scheduler only when possible.
* Return nullopt in other cases.
* Terminate on exception.

Add a regression test:
  parallel_scheduler used as the start scheduler in receiver_proxy's start_schedular_t query.
@copy-pr-bot

copy-pr-bot Bot commented Aug 23, 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.

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.

1 participant