24 static_assert(!std::is_abstract_v<T>);
27 template<
typename U = T, std::enable_if_t<std::is_
void_v<U>> * =
nullptr>
29 : d(QXmpp::Private::TaskPrivate(
nullptr))
33 template<
typename U = T, std::enable_if_t<!std::is_
void_v<U>> * =
nullptr>
35 : d(QXmpp::Private::TaskPrivate([](
void *r) {
delete static_cast<T *
>(r); }))
48 template<
typename U,
typename TT = T, std::enable_if_t<!std::is_
void_v<TT> && std::is_same_v<TT, U>> * =
nullptr>
49 void finish(U &&value)
52 Q_ASSERT(!d.isFinished());
54 if (d.continuation()) {
55 if (d.isContextAlive()) {
56 d.invokeContinuation(&value);
59 d.setResult(
new U(std::move(value)));
64 template<
typename U,
typename TT = T, std::enable_if_t<!std::is_
void_v<TT> && std::is_constructible_v<TT, U> && !std::is_same_v<TT, U>> * =
nullptr>
65 void finish(U &&value)
67 Q_ASSERT(!d.isFinished());
69 if (d.continuation()) {
70 if (d.isContextAlive()) {
71 T convertedValue { std::move(value) };
72 d.invokeContinuation(&convertedValue);
75 d.setResult(
new T(std::move(value)));
79 template<
typename U = T, std::enable_if_t<std::is_
void_v<U>> * =
nullptr>
82 Q_ASSERT(!d.isFinished());
84 if (d.continuation()) {
85 if (d.isContextAlive()) {
86 d.invokeContinuation(
nullptr);
102 QXmpp::Private::TaskPrivate d;
Create and update QXmppTask objects to communicate results of asynchronous operations.
Definition: QXmppPromise.h:23
void reportFinished(T &&value)
Definition: QXmppPromise.h:46
QXmppTask< T > task()
Definition: QXmppPromise.h:96
Definition: QXmppTask.h:62