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>;
63 if constexpr (Promise::IsVoid)
66 return static_cast<bool> (
promise.Ret_);
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);
179 std::swap (Handle_,
other.Handle_);
184 std::swap (Handle_,
other.Handle_);
188 auto operator co_await ()
const noexcept
196 template<
typename R,
template<
typename>
typename... Extensions>
Task & operator=(const Task &other)
Task(Task &&other) noexcept
Task(const std::coroutine_handle< promise_type > &handle)
Container< T > Filter(const Container< T > &c, F f)
std::suspend_never initial_suspend() const noexcept
auto final_suspend() noexcept
QVector< std::coroutine_handle<> > WaitingHandles_
void unhandled_exception()
std::exception_ptr Exception_
bool await_ready() const noexcept
decltype(auto) await_resume() const noexcept
bool await_suspend(std::coroutine_handle< Promise > handle) const noexcept
typename Task< R, Extensions... >::promise_type Promise
void return_void() noexcept
static constexpr bool IsVoid
void return_value(U &&val)
bool await_ready() const noexcept
std::coroutine_handle< Promise > Handle_t
void await_suspend(std::coroutine_handle<> handle)
auto await_resume() const