25 constexpr
static bool IsVoid =
false;
32 Ret_.emplace (std::forward<U> (val));
51 template<
typename Promise>
54 using Handle_t = std::coroutine_handle<Promise>;
59 const auto& promise =
Handle_.promise ();
60 if (promise.Exception_)
63 if constexpr (Promise::IsVoid)
66 return static_cast<bool> (promise.Ret_);
71 Handle_.promise ().WaitingHandles_.push_back (handle);
76 const auto& promise =
Handle_.promise ();
77 if (promise.Exception_)
80 std::rethrow_exception (promise.Exception_);
86 if constexpr (!Promise::IsVoid)
92 template<
typename R,
template<
typename>
typename... Extensions>
98 using Handle_t = std::coroutine_handle<promise_type>;
102 , Extensions<promise_type>...
108 auto GetAddress () {
return Handle_t::from_promise (*this).address (); }
112 return Task { Handle_t::from_promise (*
this) };
121 using Base = Extensions<promise_type>;
122 if constexpr (
requires (Base t) { t.FinalSuspend (); })
123 Base::FinalSuspend ();
141 Handle_t::from_promise (*this).destroy ();
147 template<
typename RR>
150 explicit Task (
const std::coroutine_handle<promise_type>& handle)
154 handle.promise ().IncRef ();
160 Handle_.promise ().DecRef ();
164 : Handle_ { other.Handle_ }
167 Handle_.promise ().IncRef ();
173 *
this = std::move (task);
196 template<
typename R,
template<
typename>
typename... Extensions>
bool await_suspend(std::coroutine_handle< Promise > handle) const noexcept
decltype(auto) await_resume() const noexcept
void swap(FDGuard &g1, FDGuard &g2)
Task(const std::coroutine_handle< promise_type > &handle)
void return_void() noexcept
Task & operator=(const Task &other)
std::coroutine_handle< Promise > Handle_t
auto final_suspend() noexcept
Task(Task &&other) noexcept
std::exception_ptr Exception_
void unhandled_exception()
QVector< std::coroutine_handle<> > WaitingHandles_
requires(Tup1Size==Tup2Size) const expr auto ZipWith(Tup1 &&tup1
bool await_ready() const noexcept
auto await_resume() const
void return_value(U &&val)
void await_suspend(std::coroutine_handle<> handle)
static constexpr bool IsVoid
auto Tup2 &&tup2 noexcept
bool await_ready() const noexcept
typename Task< R, Extensions... >::promise_type Promise
std::suspend_never initial_suspend() const noexcept