File indexing completed on 2024-05-05 05:37:15
0001 /* 0002 * SPDX-FileCopyrightText: 2017 Ivan Čukić <ivan.cukic(at)kde.org> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #ifndef ASYNQT_AWAIT_H 0008 #define ASYNQT_AWAIT_H 0009 0010 #include <QCoreApplication> 0011 0012 namespace AsynQt 0013 { 0014 template<typename T> 0015 T await(const QFuture<T> &future) 0016 { 0017 while (!future.isFinished()) { 0018 QCoreApplication::processEvents(); 0019 } 0020 0021 return future.result(); 0022 } 0023 0024 inline void await(const QFuture<void> &future) 0025 { 0026 while (!future.isFinished()) { 0027 QCoreApplication::processEvents(); 0028 } 0029 } 0030 0031 } // namespace AsynQt 0032 0033 #endif // ASYNQT_AWAIT_H