File indexing completed on 2024-04-28 16:53:07
0001 /* 0002 * SPDX-FileCopyrightText: 2016 Ivan Cukic <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_BASE_FLATTEN_H 0008 #define ASYNQT_BASE_FLATTEN_H 0009 0010 #include <QFuture> 0011 #include <QFutureWatcher> 0012 0013 #include <memory> 0014 #include <type_traits> 0015 0016 #include "../private/operations/flatten_p.h" 0017 0018 namespace AsynQt 0019 { 0020 /** 0021 * Takes a future of a future, and flattens it out. 0022 * 0023 * If any of the futures is canceled, the resulting future 0024 * will be canceled as well. 0025 * 0026 * @arg future future that contains another future of type T 0027 * @returns a single-level future of type T 0028 */ 0029 template<typename _Result> 0030 QFuture<_Result> flatten(const QFuture<QFuture<_Result>> &future) 0031 { 0032 return detail::flatten_impl(future); 0033 } 0034 0035 namespace operators 0036 { 0037 inline detail::operators::FlattenModifier flatten() 0038 { 0039 return detail::operators::FlattenModifier(); 0040 } 0041 0042 } // namespace operators 0043 0044 } // namespace AsynQt 0045 0046 #endif // ASYNQT_BASE_FLATTEN_H