13 #include <QMetaObject> 16 #include "../threadsconfig.h" 40 if constexpr (
requires {
operator co_await (std::forward<T> (obj)); })
41 return operator co_await (std::forward<T> (obj));
42 else if constexpr (
requires { std::forward<T> (obj).
operator co_await (); })
43 return std::forward<T> (obj).operator co_await ();
45 return std::forward<T> (obj);
50 template<
typename Promise,
typename OrigAwaiter>
58 return Orig_.await_ready ();
63 return Orig_.await_suspend (handle);
69 return Orig_.await_resume ();
79 : Context_ { context }
88 template<
typename Promise>
92 auto conn = QObject::connect (&Context_,
94 [handle] (QObject *
object)
96 auto className =
object->metaObject ()->className ();
97 handle.promise ().DeadObjects_.push_back ({ className,
object->objectName () });
100 handle.promise ().ContextConnections_.push_back (conn);
120 QObject::disconnect (conn);
131 using OrigAwaiter = decltype (
detail::Awaiter (std::forward<T> (awaitable)));
decltype(auto) await_suspend(auto handle)
QVector< QMetaObject::Connection > ContextConnections_
decltype(auto) Awaiter(T &&obj)
void CheckDeadObjects(const QVector< DeadObjectInfo > &deadObjects)
AddContextObject(QObject &context)
decltype(auto) await_resume()
bool await_ready() const noexcept
requires(Tup1Size==Tup2Size) const expr auto ZipWith(Tup1 &&tup1
void HasContextExtensions
auto await_transform(T &&awaitable)
void FinalSuspend() const noexcept
QVector< detail::DeadObjectInfo > DeadObjects_
auto Tup2 &&tup2 noexcept
bool await_suspend(std::coroutine_handle< Promise > handle)
AddContextObject await_transform(AddContextObject awaitable) const