Skip to content

Commit

Permalink
Try improving connect_awaitable's return address
Browse files Browse the repository at this point in the history
  • Loading branch information
ispeters committed Sep 12, 2024
1 parent bdefd9f commit 987a18c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion include/unifex/connect_awaitable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,19 @@ inline const struct _fn {
bool WithAsyncStackSupport = !UNIFEX_NO_ASYNC_STACKS>
auto operator()(Awaitable&& awaitable, Receiver&& receiver) const
-> _await::sender_task<remove_cvref_t<Receiver>, WithAsyncStackSupport> {
auto returnAddress = instruction_ptr::read_return_address();

if constexpr (is_tag_invocable_v<tag_t<get_return_address>, Awaitable>) {
// the awaitable has customized get_return_address so let's use its value
// rather than synthesizing one inside the connect machinery we're
// implementing
returnAddress = get_return_address(awaitable);
}

return connect_impl<WithAsyncStackSupport>(
std::forward<Awaitable>(awaitable),
std::forward<Receiver>(receiver),
instruction_ptr::read_return_address());
returnAddress);
}
} connect_awaitable{};
} // namespace _await_cpo
Expand Down

0 comments on commit 987a18c

Please sign in to comment.