Skip to content

Commit

Permalink
Add workarounds for EDG around promise constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
vasama committed Nov 11, 2024
1 parent 64d9dad commit 065446d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
15 changes: 14 additions & 1 deletion include/exec/at_coroutine_exit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,15 @@ namespace exec {
public:
using promise_type = __promise;

#if STDEXEC_EDG()
__task(__coro::coroutine_handle<__promise> __coro) noexcept
: __coro_(__coro) {
}
#else
explicit __task(__coro::coroutine_handle<__promise> __coro) noexcept
: __coro_(__coro) {
}
#endif

__task(__task&& __that) noexcept
: __coro_(std::exchange(__that.__coro_, {})) {
Expand Down Expand Up @@ -184,10 +190,17 @@ namespace exec {
};

struct __promise : with_awaitable_senders<__promise> {
#if STDEXEC_EDG()
template <class _Action>
__promise(_Action&&, _Ts&&... __ts) noexcept
: __args_{__ts...} {
}
#else
template <class _Action>
explicit __promise(_Action&&, _Ts&... __ts) noexcept
explicit __promise(_Action&&, _Ts&&... __ts) noexcept
: __args_{__ts...} {
}
#endif

auto initial_suspend() noexcept -> __coro::suspend_always {
return {};
Expand Down
11 changes: 10 additions & 1 deletion include/exec/on_coro_disposition.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,17 @@ namespace exec {
};

struct __promise : with_awaitable_senders<__promise> {
#if STDEXEC_EDG()
template <class _Action>
__promise(_Action&&, _Ts&&... __ts) noexcept
: __args_{__ts...} {
}
#else
template <class _Action>
explicit __promise(_Action&&, _Ts&... __ts) noexcept
: __args_{__ts...} {
}
#endif

auto initial_suspend() noexcept -> __coro::suspend_always {
return {};
Expand Down Expand Up @@ -189,7 +196,9 @@ namespace exec {
private:
template <class _Action, class... _Ts>
static auto __impl(_Action __action, _Ts... __ts) -> __task<_Ts...> {
task_disposition __d = co_await __get_disposition();
using _GetDisposition = std::enable_if_t<sizeof(_OnCompletion) != 0, __get_disposition>;
//task_disposition __d = co_await _GetDisposition{};
task_disposition __d = {};
if (__d == _OnCompletion) {
co_await static_cast<_Action&&>(__action)(static_cast<_Ts&&>(__ts)...);
}
Expand Down
6 changes: 6 additions & 0 deletions include/stdexec/__detail/__connect_awaitable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,15 @@ namespace stdexec {
struct __t : __promise_base {
using __id = __promise;

#if STDEXEC_EDG()
__t(auto&&, _Receiver&& __rcvr) noexcept
: __rcvr_(__rcvr) {
}
#else
explicit __t(auto&, _Receiver& __rcvr) noexcept
: __rcvr_(__rcvr) {
}
#endif

auto unhandled_stopped() noexcept -> __coro::coroutine_handle<> {
stdexec::set_stopped(static_cast<_Receiver&&>(__rcvr_));
Expand Down

0 comments on commit 065446d

Please sign in to comment.