Skip to content

Commit

Permalink
FutureUtils: Remove dead QFuture code
Browse files Browse the repository at this point in the history
The functions awaitLast, reportFinishedResult, taskFromFuture are not
used anymore.
  • Loading branch information
lnjX committed Apr 6, 2024
1 parent 04fca48 commit 479e4e3
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 39 deletions.
38 changes: 0 additions & 38 deletions src/base/QXmppFutureUtils_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,6 @@ inline QXmppTask<void> makeReadyTask()
return promise.task();
}

template<typename T, typename Handler>
void awaitLast(const QFuture<T> &future, QObject *context, Handler handler)
{
auto *watcher = new QFutureWatcher<T>(context);
QObject::connect(watcher, &QFutureWatcherBase::finished,
context, [watcher, handler = std::move(handler)]() mutable {
auto future = watcher->future();
handler(future.resultAt(future.resultCount() - 1));
watcher->deleteLater();
});
watcher->setFuture(future);
}

template<typename T, typename Handler>
void await(const QFuture<T> &future, QObject *context, Handler handler)
{
Expand Down Expand Up @@ -193,13 +180,6 @@ auto chainIq(QXmppTask<Input> &&input, QObject *context) -> QXmppTask<Result>
});
}

template<typename T>
void reportFinishedResult(QFutureInterface<T> &interface, const T &result)
{
interface.reportResult(result);
interface.reportFinished();
}

template<typename T, typename Err, typename Function>
auto mapSuccess(std::variant<T, Err> var, Function lambda)
{
Expand All @@ -215,24 +195,6 @@ auto mapSuccess(std::variant<T, Err> var, Function lambda)
std::move(var));
}

template<typename T>
static auto taskFromFuture(QFuture<T> &&future) -> QXmppTask<T>
{
QXmppPromise<T> promise;
auto *watcher = new QFutureWatcher<T>();
QObject::connect(watcher, &QFutureWatcher<T>::finished, [promise = std::move(promise), watcher]() mutable {
if constexpr (std::is_void_v<T>) {
promise.finish();
} else {
promise.finish(watcher->result());
}
watcher->deleteLater();
});
watcher->setFuture(future);

return promise.task();
}

} // namespace QXmpp::Private

#endif // QXMPPFUTUREUTILS_P_H
1 change: 0 additions & 1 deletion src/base/QXmppUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,6 @@ void QXmpp::Private::writeOptionalXmlTextElement(QXmlStreamWriter *writer, QStri
}
}


void QXmpp::Private::writeEmptyElement(QXmlStreamWriter *writer, QStringView name, QStringView xmlns)
{
writer->writeStartElement(toString65(name));
Expand Down

0 comments on commit 479e4e3

Please sign in to comment.