Fix __receiver_proxy_base start_scheduler_t query. - #2225
Open
yulin25 wants to merge 2 commits into
Open
Conversation
* 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Current behaviour
When start scheduler is queried, __receiver_proxy_base does:
task_scheduler, we just declarethat there is no start scheduler, and the query returns
nullopt.task_scheduler.task_schedulerconstructedfrom the start scheduler. And if the constructor throws,
std::terminate()is automatically invoked as querying is noexcept.task_schedulercreated withinline_scheduler. Again,std::terminate()on exception.There is one problem I encountered currently
This code does not compile:
That is
parallel_schedulerbeing the start schedulerwhich does not satisfies
task_schedulerconstructor's constraints, caused compilation failure.task_scheduleris not namedany_scheduler, which means some scheduler types can not be used to construct atask_scheduler, but 2.1 does not check that.Fixes in this PR
If the start scheduler can not be used to construct a
task_scheduler, and the user is explicitly requestinga
task_scheduler, then there is no such start scheduler of the requested type.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>.
Current implementation returns
inline_schedulerwhenq(env)is not well-formed, which should benulloptaccording to the standard.When the start scheduler's type is not
task_scheduler, return an implementation-defined value of typeoptional<task_scheduler>:task_scheduler, return constructedtask_scheduler.