Repository navigation
exec(fork_join): coalesce empty and unary calls #2302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -43,6 +43,30 @@ namespace | |||||||||||||||||||||||
| completion_signatures<set_value_t(), set_error_t(std::exception_ptr)>>); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| TEST_CASE("fork_join coalesces empty and unary calls", "[adaptors][fork_join]") | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| /// Empty (no closure given). | ||||||||||||||||||||||||
| STDEXEC::sender auto empty = exec::fork_join(STDEXEC::just()); | ||||||||||||||||||||||||
| using empty_t = decltype(empty); | ||||||||||||||||||||||||
| STATIC_REQUIRE(std::same_as<empty_t, decltype(STDEXEC::just())>); | ||||||||||||||||||||||||
| STATIC_REQUIRE(!exec::sender_for<empty_t, exec::fork_join_t>); | ||||||||||||||||||||||||
| STATIC_REQUIRE(noexcept(exec::fork_join(STDEXEC::just()))); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| auto then = STDEXEC::then([]() noexcept {}); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| /// Unary closure. | ||||||||||||||||||||||||
| STDEXEC::sender auto unary = exec::fork_join(STDEXEC::just(), then); | ||||||||||||||||||||||||
| using unary_t = decltype(unary); | ||||||||||||||||||||||||
| STATIC_REQUIRE(std::same_as<unary_t, decltype(STDEXEC::just() | then)>); | ||||||||||||||||||||||||
| STATIC_REQUIRE(!exec::sender_for<unary_t, exec::fork_join_t>); | ||||||||||||||||||||||||
| STATIC_REQUIRE(noexcept(exec::fork_join(STDEXEC::just(), then))); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| /// Multiple closures. | ||||||||||||||||||||||||
| STDEXEC::sender auto multiple = STDEXEC::just() | exec::fork_join(then, then); | ||||||||||||||||||||||||
| STATIC_REQUIRE(exec::sender_for<decltype(multiple), exec::fork_join_t>); | ||||||||||||||||||||||||
| STATIC_REQUIRE(!noexcept(exec::fork_join(STDEXEC::just(), then, then))); | ||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could also omit this line. Because it seems the reason is that the function has no noexcept clause, rather than that one operations may throw.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, but at least it's tested.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would expect constructing such an
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are 2 functions in the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My two cents would be to add the noexcept clause and flip the static_assert here. We could write something like (perhaps there's a way to make it less verbose with other concepts from The last two checks would be needed for the moves here: stdexec/include/stdexec/__detail/__basic_sender.hpp Lines 460 to 470 in f4c123f
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ericniebler What do you think?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should probably fix
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That change has now landed and i have merged it into this PR, so the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok! Thank you very much for the pr and merging it here. To write the noexcept clause, one remaining question seems to be whether we should take into account the move of the __tuple that fork_join constructs and then passes to __make_sexpr? |
||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| struct ForwardingThen | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| template <typename Value> | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.