Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- qt/6.8.1/msvc2022_64/include/QtConcurrent/QtConcurrent +20 -0
- qt/6.8.1/msvc2022_64/include/QtConcurrent/QtConcurrentDepends +4 -0
- qt/6.8.1/msvc2022_64/include/QtConcurrent/QtConcurrentFilter +1 -0
- qt/6.8.1/msvc2022_64/include/QtConcurrent/QtConcurrentMap +1 -0
- qt/6.8.1/msvc2022_64/include/QtConcurrent/QtConcurrentRun +1 -0
- qt/6.8.1/msvc2022_64/include/QtConcurrent/QtConcurrentVersion +1 -0
- qt/6.8.1/msvc2022_64/include/QtConcurrent/qtaskbuilder.h +135 -0
- qt/6.8.1/msvc2022_64/include/QtConcurrent/qtconcurrent_global.h +10 -0
- qt/6.8.1/msvc2022_64/include/QtConcurrent/qtconcurrentcompilertest.h +41 -0
- qt/6.8.1/msvc2022_64/include/QtConcurrent/qtconcurrentexports.h +50 -0
- qt/6.8.1/msvc2022_64/include/QtConcurrent/qtconcurrentfilter.h +719 -0
- qt/6.8.1/msvc2022_64/include/QtConcurrent/qtconcurrentfilterkernel.h +386 -0
- qt/6.8.1/msvc2022_64/include/QtConcurrent/qtconcurrentfunctionwrappers.h +179 -0
- qt/6.8.1/msvc2022_64/include/QtConcurrent/qtconcurrentiteratekernel.h +335 -0
- qt/6.8.1/msvc2022_64/include/QtConcurrent/qtconcurrentmap.h +823 -0
- qt/6.8.1/msvc2022_64/include/QtConcurrent/qtconcurrentmapkernel.h +327 -0
- qt/6.8.1/msvc2022_64/include/QtConcurrent/qtconcurrentmedian.h +90 -0
- qt/6.8.1/msvc2022_64/include/QtConcurrent/qtconcurrentreducekernel.h +237 -0
- qt/6.8.1/msvc2022_64/include/QtConcurrent/qtconcurrentrun.h +96 -0
- qt/6.8.1/msvc2022_64/include/QtConcurrent/qtconcurrentrunbase.h +108 -0
- qt/6.8.1/msvc2022_64/include/QtConcurrent/qtconcurrentstoredfunctioncall.h +230 -0
- qt/6.8.1/msvc2022_64/include/QtConcurrent/qtconcurrenttask.h +39 -0
- qt/6.8.1/msvc2022_64/include/QtConcurrent/qtconcurrentthreadengine.h +224 -0
- qt/6.8.1/msvc2022_64/include/QtConcurrent/qtconcurrentversion.h +9 -0
- qt/6.8.1/msvc2022_64/include/QtCore/QAbstractAnimation +1 -0
- qt/6.8.1/msvc2022_64/include/QtCore/QAbstractEventDispatcher +1 -0
- qt/6.8.1/msvc2022_64/include/QtCore/QAbstractEventDispatcherV2 +1 -0
- qt/6.8.1/msvc2022_64/include/QtCore/QAbstractItemModel +1 -0
- qt/6.8.1/msvc2022_64/include/QtCore/QAbstractListModel +1 -0
- qt/6.8.1/msvc2022_64/include/QtCore/QAbstractNativeEventFilter +1 -0
- qt/6.8.1/msvc2022_64/include/QtCore/QAbstractProxyModel +1 -0
- qt/6.8.1/msvc2022_64/include/QtCore/QAbstractTableModel +1 -0
- qt/6.8.1/msvc2022_64/include/QtCore/QAnimationDriver +1 -0
- qt/6.8.1/msvc2022_64/include/QtCore/QAnimationGroup +1 -0
- qt/6.8.1/msvc2022_64/include/QtCore/QAnyStringView +1 -0
- qt/6.8.1/msvc2022_64/include/QtCore/QApplicationStatic +1 -0
- qt/6.8.1/msvc2022_64/include/QtCore/QArgument +1 -0
- qt/6.8.1/msvc2022_64/include/QtCore/QArrayData +1 -0
- qt/6.8.1/msvc2022_64/include/QtCore/QArrayDataOps +1 -0
- qt/6.8.1/msvc2022_64/include/QtCore/q20algorithm.h +191 -0
- qt/6.8.1/msvc2022_64/include/QtCore/q20chrono.h +62 -0
- qt/6.8.1/msvc2022_64/include/QtCore/q20functional.h +46 -0
- qt/6.8.1/msvc2022_64/include/QtCore/q20iterator.h +54 -0
- qt/6.8.1/msvc2022_64/include/QtCore/q20map.h +72 -0
- qt/6.8.1/msvc2022_64/include/QtCore/q20memory.h +93 -0
- qt/6.8.1/msvc2022_64/include/QtCore/q20type_traits.h +81 -0
- qt/6.8.1/msvc2022_64/include/QtCore/q20vector.h +90 -0
- qt/6.8.1/msvc2022_64/include/QtCore/q23functional.h +49 -0
- qt/6.8.1/msvc2022_64/include/QtCore/q23utility.h +75 -0
- qt/6.8.1/msvc2022_64/include/QtCore/q26numeric.h +69 -0
qt/6.8.1/msvc2022_64/include/QtConcurrent/QtConcurrent
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#ifndef QT_QTCONCURRENT_MODULE_H
|
| 2 |
+
#define QT_QTCONCURRENT_MODULE_H
|
| 3 |
+
#include <QtConcurrent/QtConcurrentDepends>
|
| 4 |
+
#include "qtaskbuilder.h"
|
| 5 |
+
#include "qtconcurrentcompilertest.h"
|
| 6 |
+
#include "qtconcurrentfilter.h"
|
| 7 |
+
#include "qtconcurrentfilterkernel.h"
|
| 8 |
+
#include "qtconcurrentfunctionwrappers.h"
|
| 9 |
+
#include "qtconcurrentiteratekernel.h"
|
| 10 |
+
#include "qtconcurrentmap.h"
|
| 11 |
+
#include "qtconcurrentmapkernel.h"
|
| 12 |
+
#include "qtconcurrentmedian.h"
|
| 13 |
+
#include "qtconcurrentreducekernel.h"
|
| 14 |
+
#include "qtconcurrentrun.h"
|
| 15 |
+
#include "qtconcurrentrunbase.h"
|
| 16 |
+
#include "qtconcurrentstoredfunctioncall.h"
|
| 17 |
+
#include "qtconcurrenttask.h"
|
| 18 |
+
#include "qtconcurrentthreadengine.h"
|
| 19 |
+
#include "qtconcurrentversion.h"
|
| 20 |
+
#endif
|
qt/6.8.1/msvc2022_64/include/QtConcurrent/QtConcurrentDepends
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file was generated by cmake with the info from Concurrent target. */
|
| 2 |
+
#ifdef __cplusplus /* create empty PCH in C mode */
|
| 3 |
+
# include <QtCore/QtCore>
|
| 4 |
+
#endif
|
qt/6.8.1/msvc2022_64/include/QtConcurrent/QtConcurrentFilter
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
#include "qtconcurrentfilter.h" // IWYU pragma: export
|
qt/6.8.1/msvc2022_64/include/QtConcurrent/QtConcurrentMap
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
#include "qtconcurrentmap.h" // IWYU pragma: export
|
qt/6.8.1/msvc2022_64/include/QtConcurrent/QtConcurrentRun
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
#include "qtconcurrentrun.h" // IWYU pragma: export
|
qt/6.8.1/msvc2022_64/include/QtConcurrent/QtConcurrentVersion
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
#include "qtconcurrentversion.h" // IWYU pragma: export
|
qt/6.8.1/msvc2022_64/include/QtConcurrent/qtaskbuilder.h
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright (C) 2020 The Qt Company Ltd.
|
| 2 |
+
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
| 3 |
+
|
| 4 |
+
#ifndef QTBASE_QTTASKBUILDER_H
|
| 5 |
+
#define QTBASE_QTTASKBUILDER_H
|
| 6 |
+
|
| 7 |
+
#if !defined(QT_NO_CONCURRENT) || defined(Q_QDOC)
|
| 8 |
+
|
| 9 |
+
#include <QtConcurrent/qtconcurrentstoredfunctioncall.h>
|
| 10 |
+
|
| 11 |
+
QT_BEGIN_NAMESPACE
|
| 12 |
+
|
| 13 |
+
#ifdef Q_QDOC
|
| 14 |
+
|
| 15 |
+
namespace QtConcurrent {
|
| 16 |
+
|
| 17 |
+
enum class FutureResult { Ignore };
|
| 18 |
+
|
| 19 |
+
using InvokeResultType = int;
|
| 20 |
+
|
| 21 |
+
template <class Task, class ...Args>
|
| 22 |
+
class QTaskBuilder
|
| 23 |
+
{
|
| 24 |
+
public:
|
| 25 |
+
[[nodiscard]]
|
| 26 |
+
QFuture<InvokeResultType> spawn();
|
| 27 |
+
|
| 28 |
+
void spawn(FutureResult);
|
| 29 |
+
|
| 30 |
+
template <class ...ExtraArgs>
|
| 31 |
+
[[nodiscard]]
|
| 32 |
+
QTaskBuilder<Task, ExtraArgs...> withArguments(ExtraArgs &&...args);
|
| 33 |
+
|
| 34 |
+
[[nodiscard]]
|
| 35 |
+
QTaskBuilder<Task, Args...> &onThreadPool(QThreadPool &newThreadPool);
|
| 36 |
+
|
| 37 |
+
[[nodiscard]]
|
| 38 |
+
QTaskBuilder<Task, Args...> &withPriority(int newPriority);
|
| 39 |
+
};
|
| 40 |
+
|
| 41 |
+
} // namespace QtConcurrent
|
| 42 |
+
|
| 43 |
+
#else
|
| 44 |
+
|
| 45 |
+
namespace QtConcurrent {
|
| 46 |
+
|
| 47 |
+
enum class FutureResult { Ignore };
|
| 48 |
+
|
| 49 |
+
template <class Task, class ...Args>
|
| 50 |
+
class QTaskBuilder
|
| 51 |
+
{
|
| 52 |
+
public:
|
| 53 |
+
[[nodiscard]]
|
| 54 |
+
auto spawn()
|
| 55 |
+
{
|
| 56 |
+
return TaskResolver<std::decay_t<Task>, std::decay_t<Args>...>::run(
|
| 57 |
+
std::move(taskWithArgs), startParameters);
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
// We don't want to run with promise when we don't return a QFuture
|
| 61 |
+
void spawn(FutureResult)
|
| 62 |
+
{
|
| 63 |
+
(new StoredFunctionCall<Task, Args...>(std::move(taskWithArgs)))
|
| 64 |
+
->start(startParameters);
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
template <class ...ExtraArgs>
|
| 68 |
+
[[nodiscard]]
|
| 69 |
+
constexpr auto withArguments(ExtraArgs &&...args)
|
| 70 |
+
{
|
| 71 |
+
static_assert(std::tuple_size_v<TaskWithArgs> == 1,
|
| 72 |
+
"This function cannot be invoked if "
|
| 73 |
+
"arguments have already been passed.");
|
| 74 |
+
|
| 75 |
+
static_assert(sizeof...(ExtraArgs) >= 1,
|
| 76 |
+
"One or more arguments must be passed.");
|
| 77 |
+
|
| 78 |
+
// We have to re-create a builder, because the type has changed
|
| 79 |
+
return QTaskBuilder<Task, ExtraArgs...>(
|
| 80 |
+
startParameters,
|
| 81 |
+
std::get<0>(std::move(taskWithArgs)),
|
| 82 |
+
std::forward<ExtraArgs>(args)...
|
| 83 |
+
);
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
[[nodiscard]]
|
| 87 |
+
constexpr auto &onThreadPool(QThreadPool &newThreadPool)
|
| 88 |
+
{
|
| 89 |
+
startParameters.threadPool = &newThreadPool;
|
| 90 |
+
return *this;
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
[[nodiscard]]
|
| 94 |
+
constexpr auto &withPriority(int newPriority)
|
| 95 |
+
{
|
| 96 |
+
startParameters.priority = newPriority;
|
| 97 |
+
return *this;
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
protected: // Methods
|
| 101 |
+
constexpr explicit QTaskBuilder(Task &&task, Args &&...arguments)
|
| 102 |
+
: taskWithArgs{std::forward<Task>(task), std::forward<Args>(arguments)...}
|
| 103 |
+
{}
|
| 104 |
+
|
| 105 |
+
constexpr QTaskBuilder(
|
| 106 |
+
const TaskStartParameters ¶meters, Task &&task, Args &&...arguments)
|
| 107 |
+
: taskWithArgs{std::forward<Task>(task), std::forward<Args>(arguments)...}
|
| 108 |
+
, startParameters{parameters}
|
| 109 |
+
{}
|
| 110 |
+
|
| 111 |
+
private: // Methods
|
| 112 |
+
// Required for creating a builder from "task" function
|
| 113 |
+
template <class T>
|
| 114 |
+
friend constexpr auto task(T &&t);
|
| 115 |
+
|
| 116 |
+
// Required for creating a new builder from "withArguments" function
|
| 117 |
+
template <class T, class ...A>
|
| 118 |
+
friend class QTaskBuilder;
|
| 119 |
+
|
| 120 |
+
private: // Data
|
| 121 |
+
using TaskWithArgs = DecayedTuple<Task, Args...>;
|
| 122 |
+
|
| 123 |
+
TaskWithArgs taskWithArgs;
|
| 124 |
+
TaskStartParameters startParameters;
|
| 125 |
+
};
|
| 126 |
+
|
| 127 |
+
} // namespace QtConcurrent
|
| 128 |
+
|
| 129 |
+
#endif // Q_QDOC
|
| 130 |
+
|
| 131 |
+
QT_END_NAMESPACE
|
| 132 |
+
|
| 133 |
+
#endif // !defined(QT_NO_CONCURRENT)
|
| 134 |
+
|
| 135 |
+
#endif //QTBASE_QTTASKBUILDER_H
|
qt/6.8.1/msvc2022_64/include/QtConcurrent/qtconcurrent_global.h
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright (C) 2016 The Qt Company Ltd.
|
| 2 |
+
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
| 3 |
+
|
| 4 |
+
#ifndef QTCONCURRENT_GLOBAL_H
|
| 5 |
+
#define QTCONCURRENT_GLOBAL_H
|
| 6 |
+
|
| 7 |
+
#include <QtCore/qglobal.h>
|
| 8 |
+
#include <QtConcurrent/qtconcurrentexports.h>
|
| 9 |
+
|
| 10 |
+
#endif // include guard
|
qt/6.8.1/msvc2022_64/include/QtConcurrent/qtconcurrentcompilertest.h
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright (C) 2016 The Qt Company Ltd.
|
| 2 |
+
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
| 3 |
+
|
| 4 |
+
#ifndef QTCONCURRENT_COMPILERTEST_H
|
| 5 |
+
#define QTCONCURRENT_COMPILERTEST_H
|
| 6 |
+
|
| 7 |
+
#include <QtConcurrent/qtconcurrent_global.h>
|
| 8 |
+
|
| 9 |
+
#ifndef QT_NO_CONCURRENT
|
| 10 |
+
|
| 11 |
+
QT_BEGIN_NAMESPACE
|
| 12 |
+
|
| 13 |
+
namespace QtPrivate {
|
| 14 |
+
|
| 15 |
+
template <class T, typename = void>
|
| 16 |
+
struct IsIterable : std::false_type {};
|
| 17 |
+
template <class T>
|
| 18 |
+
struct IsIterable<T, std::void_t<decltype(std::declval<T>().begin()),
|
| 19 |
+
decltype(std::declval<T>().end())>>
|
| 20 |
+
: std::true_type
|
| 21 |
+
{ };
|
| 22 |
+
|
| 23 |
+
template <class T>
|
| 24 |
+
inline constexpr bool IsIterableValue = IsIterable<T>::value;
|
| 25 |
+
|
| 26 |
+
template <class T, typename = void>
|
| 27 |
+
struct IsDereferenceable : std::false_type {};
|
| 28 |
+
template <class T>
|
| 29 |
+
struct IsDereferenceable<T, std::void_t<decltype(*std::declval<T>())>>
|
| 30 |
+
: std::true_type
|
| 31 |
+
{ };
|
| 32 |
+
|
| 33 |
+
template <class T>
|
| 34 |
+
inline constexpr bool IsDereferenceableValue = IsDereferenceable<T>::value;
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
QT_END_NAMESPACE
|
| 38 |
+
|
| 39 |
+
#endif // QT_NO_CONCURRENT
|
| 40 |
+
|
| 41 |
+
#endif
|
qt/6.8.1/msvc2022_64/include/QtConcurrent/qtconcurrentexports.h
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright (C) 2022 The Qt Company Ltd.
|
| 2 |
+
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
| 3 |
+
|
| 4 |
+
#ifndef QTCONCURRENTEXPORTS_H
|
| 5 |
+
#define QTCONCURRENTEXPORTS_H
|
| 6 |
+
|
| 7 |
+
#include <QtCore/qcompilerdetection.h>
|
| 8 |
+
#include <QtCore/qtconfigmacros.h> // Q_CONCURRENT_EXPORT
|
| 9 |
+
#include <QtCore/qtdeprecationmarkers.h> // QT_IF_DEPRECATED_SINCE
|
| 10 |
+
|
| 11 |
+
#if defined(QT_SHARED) || !defined(QT_STATIC)
|
| 12 |
+
# if defined(QT_BUILD_CONCURRENT_LIB)
|
| 13 |
+
# define Q_CONCURRENT_EXPORT Q_DECL_EXPORT
|
| 14 |
+
# else
|
| 15 |
+
# define Q_CONCURRENT_EXPORT Q_DECL_IMPORT
|
| 16 |
+
# endif
|
| 17 |
+
#else
|
| 18 |
+
# define Q_CONCURRENT_EXPORT
|
| 19 |
+
#endif
|
| 20 |
+
|
| 21 |
+
#if !defined(QT_BUILD_CONCURRENT_LIB) && !defined(QT_STATIC)
|
| 22 |
+
/* outside library -> inline decl + defi */
|
| 23 |
+
/* static builds treat everything as part of the library, so they never inline */
|
| 24 |
+
# define QT_CONCURRENT_INLINE_SINCE(major, minor) inline
|
| 25 |
+
# define QT_CONCURRENT_INLINE_IMPL_SINCE(major, minor) 1
|
| 26 |
+
#elif defined(QT_CONCURRENT_BUILD_REMOVED_API)
|
| 27 |
+
/* inside library, inside removed_api.cpp:
|
| 28 |
+
* keep deprecated API -> non-inline decl;
|
| 29 |
+
* remove deprecated API -> inline decl;
|
| 30 |
+
* definition is always available */
|
| 31 |
+
# define QT_CONCURRENT_INLINE_SINCE(major, minor) \
|
| 32 |
+
QT_IF_DEPRECATED_SINCE(major, minor, inline, /* not inline */)
|
| 33 |
+
# define QT_CONCURRENT_INLINE_IMPL_SINCE(major, minor) 1
|
| 34 |
+
#else
|
| 35 |
+
/* inside library, outside removed_api.cpp:
|
| 36 |
+
* keep deprecated API -> non-inline decl, no defi;
|
| 37 |
+
* remove deprecated API -> inline decl, defi */
|
| 38 |
+
# define QT_CONCURRENT_INLINE_SINCE(major, minor) \
|
| 39 |
+
QT_IF_DEPRECATED_SINCE(major, minor, inline, /* not inline */)
|
| 40 |
+
# define QT_CONCURRENT_INLINE_IMPL_SINCE(major, minor) \
|
| 41 |
+
QT_IF_DEPRECATED_SINCE(major, minor, 1, 0)
|
| 42 |
+
#endif
|
| 43 |
+
|
| 44 |
+
#ifdef QT_CONCURRENT_BUILD_REMOVED_API
|
| 45 |
+
# define QT_CONCURRENT_REMOVED_SINCE(major, minor) QT_DEPRECATED_SINCE(major, minor)
|
| 46 |
+
#else
|
| 47 |
+
# define QT_CONCURRENT_REMOVED_SINCE(major, minor) 0
|
| 48 |
+
#endif
|
| 49 |
+
|
| 50 |
+
#endif // QTCONCURRENTEXPORTS_H
|
qt/6.8.1/msvc2022_64/include/QtConcurrent/qtconcurrentfilter.h
ADDED
|
@@ -0,0 +1,719 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright (C) 2016 The Qt Company Ltd.
|
| 2 |
+
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
| 3 |
+
|
| 4 |
+
#ifndef QTCONCURRENT_FILTER_H
|
| 5 |
+
#define QTCONCURRENT_FILTER_H
|
| 6 |
+
|
| 7 |
+
#if 0
|
| 8 |
+
#pragma qt_class(QtConcurrentFilter)
|
| 9 |
+
#endif
|
| 10 |
+
|
| 11 |
+
#include <QtConcurrent/qtconcurrent_global.h>
|
| 12 |
+
|
| 13 |
+
#if !defined(QT_NO_CONCURRENT) || defined(Q_QDOC)
|
| 14 |
+
|
| 15 |
+
#include <QtConcurrent/qtconcurrentfilterkernel.h>
|
| 16 |
+
#include <QtConcurrent/qtconcurrentfunctionwrappers.h>
|
| 17 |
+
|
| 18 |
+
QT_BEGIN_NAMESPACE
|
| 19 |
+
|
| 20 |
+
namespace QtConcurrent {
|
| 21 |
+
|
| 22 |
+
//! [QtConcurrent-1]
|
| 23 |
+
template <typename Sequence, typename KeepFunctor, typename ReduceFunctor>
|
| 24 |
+
ThreadEngineStarter<void> filterInternal(QThreadPool *pool, Sequence &sequence,
|
| 25 |
+
KeepFunctor &&keep, ReduceFunctor &&reduce)
|
| 26 |
+
{
|
| 27 |
+
typedef FilterKernel<Sequence, std::decay_t<KeepFunctor>, std::decay_t<ReduceFunctor>>
|
| 28 |
+
KernelType;
|
| 29 |
+
return startThreadEngine(new KernelType(pool, sequence, std::forward<KeepFunctor>(keep),
|
| 30 |
+
std::forward<ReduceFunctor>(reduce)));
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
// filter() on sequences
|
| 34 |
+
template <typename Sequence, typename KeepFunctor>
|
| 35 |
+
QFuture<void> filter(QThreadPool *pool, Sequence &sequence, KeepFunctor &&keep)
|
| 36 |
+
{
|
| 37 |
+
return filterInternal(pool, sequence, std::forward<KeepFunctor>(keep),
|
| 38 |
+
QtPrivate::PushBackWrapper());
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
template <typename Sequence, typename KeepFunctor>
|
| 42 |
+
QFuture<void> filter(Sequence &sequence, KeepFunctor &&keep)
|
| 43 |
+
{
|
| 44 |
+
return filterInternal(QThreadPool::globalInstance(),
|
| 45 |
+
sequence, std::forward<KeepFunctor>(keep), QtPrivate::PushBackWrapper());
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
// filteredReduced() on sequences
|
| 49 |
+
template <typename ResultType, typename Sequence, typename KeepFunctor, typename ReduceFunctor>
|
| 50 |
+
QFuture<ResultType> filteredReduced(QThreadPool *pool,
|
| 51 |
+
Sequence &&sequence,
|
| 52 |
+
KeepFunctor &&keep,
|
| 53 |
+
ReduceFunctor &&reduce,
|
| 54 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 55 |
+
| SequentialReduce))
|
| 56 |
+
{
|
| 57 |
+
return startFilteredReduced<ResultType>(pool, std::forward<Sequence>(sequence),
|
| 58 |
+
std::forward<KeepFunctor>(keep),
|
| 59 |
+
std::forward<ReduceFunctor>(reduce), options);
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
template <typename ResultType, typename Sequence, typename KeepFunctor, typename ReduceFunctor>
|
| 63 |
+
QFuture<ResultType> filteredReduced(Sequence &&sequence,
|
| 64 |
+
KeepFunctor &&keep,
|
| 65 |
+
ReduceFunctor &&reduce,
|
| 66 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 67 |
+
| SequentialReduce))
|
| 68 |
+
{
|
| 69 |
+
return startFilteredReduced<ResultType>(
|
| 70 |
+
QThreadPool::globalInstance(), std::forward<Sequence>(sequence),
|
| 71 |
+
std::forward<KeepFunctor>(keep), std::forward<ReduceFunctor>(reduce), options);
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
#ifdef Q_QDOC
|
| 75 |
+
template <typename ResultType, typename Sequence, typename KeepFunctor, typename ReduceFunctor,
|
| 76 |
+
typename InitialValueType>
|
| 77 |
+
#else
|
| 78 |
+
template <typename ResultType, typename Sequence, typename KeepFunctor, typename ReduceFunctor,
|
| 79 |
+
typename InitialValueType,
|
| 80 |
+
std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
|
| 81 |
+
int> = 0>
|
| 82 |
+
#endif
|
| 83 |
+
QFuture<ResultType> filteredReduced(QThreadPool *pool,
|
| 84 |
+
Sequence &&sequence,
|
| 85 |
+
KeepFunctor &&keep,
|
| 86 |
+
ReduceFunctor &&reduce,
|
| 87 |
+
InitialValueType &&initialValue,
|
| 88 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 89 |
+
| SequentialReduce))
|
| 90 |
+
{
|
| 91 |
+
return startFilteredReduced<ResultType>(
|
| 92 |
+
pool, std::forward<Sequence>(sequence), std::forward<KeepFunctor>(keep),
|
| 93 |
+
std::forward<ReduceFunctor>(reduce),
|
| 94 |
+
ResultType(std::forward<InitialValueType>(initialValue)), options);
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
#ifdef Q_QDOC
|
| 98 |
+
template <typename ResultType, typename Sequence, typename KeepFunctor, typename ReduceFunctor,
|
| 99 |
+
typename InitialValueType>
|
| 100 |
+
#else
|
| 101 |
+
template <typename ResultType, typename Sequence, typename KeepFunctor, typename ReduceFunctor,
|
| 102 |
+
typename InitialValueType,
|
| 103 |
+
std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
|
| 104 |
+
int> = 0>
|
| 105 |
+
#endif
|
| 106 |
+
QFuture<ResultType> filteredReduced(Sequence &&sequence,
|
| 107 |
+
KeepFunctor &&keep,
|
| 108 |
+
ReduceFunctor &&reduce,
|
| 109 |
+
InitialValueType &&initialValue,
|
| 110 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 111 |
+
| SequentialReduce))
|
| 112 |
+
{
|
| 113 |
+
return startFilteredReduced<ResultType>(
|
| 114 |
+
QThreadPool::globalInstance(), std::forward<Sequence>(sequence),
|
| 115 |
+
std::forward<KeepFunctor>(keep), std::forward<ReduceFunctor>(reduce),
|
| 116 |
+
ResultType(std::forward<InitialValueType>(initialValue)), options);
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
#ifndef Q_QDOC
|
| 120 |
+
template <typename Sequence, typename KeepFunctor, typename ReduceFunctor,
|
| 121 |
+
std::enable_if_t<QtPrivate::isInvocable<KeepFunctor, Sequence>::value, int> = 0,
|
| 122 |
+
typename ResultType = typename QtPrivate::ReduceResultTypeHelper<ReduceFunctor>::type>
|
| 123 |
+
QFuture<ResultType> filteredReduced(QThreadPool *pool,
|
| 124 |
+
Sequence &&sequence,
|
| 125 |
+
KeepFunctor &&keep,
|
| 126 |
+
ReduceFunctor &&reduce,
|
| 127 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 128 |
+
| SequentialReduce))
|
| 129 |
+
{
|
| 130 |
+
return startFilteredReduced<ResultType>(pool, std::forward<Sequence>(sequence),
|
| 131 |
+
std::forward<KeepFunctor>(keep),
|
| 132 |
+
std::forward<ReduceFunctor>(reduce), options);
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
template <typename Sequence, typename KeepFunctor, typename ReduceFunctor,
|
| 136 |
+
std::enable_if_t<QtPrivate::isInvocable<KeepFunctor, Sequence>::value, int> = 0,
|
| 137 |
+
typename ResultType = typename QtPrivate::ReduceResultTypeHelper<ReduceFunctor>::type>
|
| 138 |
+
QFuture<ResultType> filteredReduced(Sequence &&sequence,
|
| 139 |
+
KeepFunctor &&keep,
|
| 140 |
+
ReduceFunctor &&reduce,
|
| 141 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 142 |
+
| SequentialReduce))
|
| 143 |
+
{
|
| 144 |
+
return startFilteredReduced<ResultType>(
|
| 145 |
+
QThreadPool::globalInstance(), std::forward<Sequence>(sequence),
|
| 146 |
+
std::forward<KeepFunctor>(keep), std::forward<ReduceFunctor>(reduce), options);
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
template <typename Sequence, typename KeepFunctor, typename ReduceFunctor,
|
| 150 |
+
typename InitialValueType,
|
| 151 |
+
std::enable_if_t<QtPrivate::isInvocable<KeepFunctor, Sequence>::value, int> = 0,
|
| 152 |
+
typename ResultType = typename QtPrivate::ReduceResultTypeHelper<ReduceFunctor>::type,
|
| 153 |
+
std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
|
| 154 |
+
int> = 0>
|
| 155 |
+
QFuture<ResultType> filteredReduced(QThreadPool *pool,
|
| 156 |
+
Sequence &&sequence,
|
| 157 |
+
KeepFunctor &&keep,
|
| 158 |
+
ReduceFunctor &&reduce,
|
| 159 |
+
InitialValueType &&initialValue,
|
| 160 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 161 |
+
| SequentialReduce))
|
| 162 |
+
{
|
| 163 |
+
return startFilteredReduced<ResultType>(
|
| 164 |
+
pool, std::forward<Sequence>(sequence), std::forward<KeepFunctor>(keep),
|
| 165 |
+
std::forward<ReduceFunctor>(reduce),
|
| 166 |
+
ResultType(std::forward<InitialValueType>(initialValue)), options);
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
template <typename Sequence, typename KeepFunctor, typename ReduceFunctor,
|
| 170 |
+
typename InitialValueType,
|
| 171 |
+
std::enable_if_t<QtPrivate::isInvocable<KeepFunctor, Sequence>::value, int> = 0,
|
| 172 |
+
typename ResultType = typename QtPrivate::ReduceResultTypeHelper<ReduceFunctor>::type,
|
| 173 |
+
std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
|
| 174 |
+
int> = 0>
|
| 175 |
+
QFuture<ResultType> filteredReduced(Sequence &&sequence,
|
| 176 |
+
KeepFunctor &&keep,
|
| 177 |
+
ReduceFunctor &&reduce,
|
| 178 |
+
InitialValueType &&initialValue,
|
| 179 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 180 |
+
| SequentialReduce))
|
| 181 |
+
{
|
| 182 |
+
return startFilteredReduced<ResultType>(
|
| 183 |
+
QThreadPool::globalInstance(), std::forward<Sequence>(sequence),
|
| 184 |
+
std::forward<KeepFunctor>(keep), std::forward<ReduceFunctor>(reduce),
|
| 185 |
+
ResultType(std::forward<InitialValueType>(initialValue)), options);
|
| 186 |
+
}
|
| 187 |
+
#endif
|
| 188 |
+
|
| 189 |
+
// filteredReduced() on iterators
|
| 190 |
+
template <typename ResultType, typename Iterator, typename KeepFunctor, typename ReduceFunctor>
|
| 191 |
+
QFuture<ResultType> filteredReduced(QThreadPool *pool,
|
| 192 |
+
Iterator begin,
|
| 193 |
+
Iterator end,
|
| 194 |
+
KeepFunctor &&keep,
|
| 195 |
+
ReduceFunctor &&reduce,
|
| 196 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 197 |
+
| SequentialReduce))
|
| 198 |
+
{
|
| 199 |
+
return startFilteredReduced<ResultType>(pool, begin, end, std::forward<KeepFunctor>(keep),
|
| 200 |
+
std::forward<ReduceFunctor>(reduce), options);
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
template <typename ResultType, typename Iterator, typename KeepFunctor, typename ReduceFunctor>
|
| 204 |
+
QFuture<ResultType> filteredReduced(Iterator begin,
|
| 205 |
+
Iterator end,
|
| 206 |
+
KeepFunctor &&keep,
|
| 207 |
+
ReduceFunctor &&reduce,
|
| 208 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 209 |
+
| SequentialReduce))
|
| 210 |
+
{
|
| 211 |
+
return startFilteredReduced<ResultType>(QThreadPool::globalInstance(), begin, end,
|
| 212 |
+
std::forward<KeepFunctor>(keep),
|
| 213 |
+
std::forward<ReduceFunctor>(reduce), options);
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
#ifdef Q_QDOC
|
| 217 |
+
template <typename ResultType, typename Iterator, typename KeepFunctor, typename ReduceFunctor,
|
| 218 |
+
typename InitialValueType>
|
| 219 |
+
#else
|
| 220 |
+
template <typename ResultType, typename Iterator, typename KeepFunctor, typename ReduceFunctor,
|
| 221 |
+
typename InitialValueType,
|
| 222 |
+
std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
|
| 223 |
+
int> = 0>
|
| 224 |
+
#endif
|
| 225 |
+
QFuture<ResultType> filteredReduced(QThreadPool *pool,
|
| 226 |
+
Iterator begin,
|
| 227 |
+
Iterator end,
|
| 228 |
+
KeepFunctor &&keep,
|
| 229 |
+
ReduceFunctor &&reduce,
|
| 230 |
+
InitialValueType &&initialValue,
|
| 231 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 232 |
+
| SequentialReduce))
|
| 233 |
+
{
|
| 234 |
+
return startFilteredReduced<ResultType>(
|
| 235 |
+
pool, begin, end, std::forward<KeepFunctor>(keep), std::forward<ReduceFunctor>(reduce),
|
| 236 |
+
ResultType(std::forward<InitialValueType>(initialValue)), options);
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
#ifdef Q_QDOC
|
| 240 |
+
template <typename ResultType, typename Iterator, typename KeepFunctor, typename ReduceFunctor,
|
| 241 |
+
typename InitialValueType>
|
| 242 |
+
#else
|
| 243 |
+
template <typename ResultType, typename Iterator, typename KeepFunctor, typename ReduceFunctor,
|
| 244 |
+
typename InitialValueType,
|
| 245 |
+
std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
|
| 246 |
+
int> = 0>
|
| 247 |
+
#endif
|
| 248 |
+
QFuture<ResultType> filteredReduced(Iterator begin,
|
| 249 |
+
Iterator end,
|
| 250 |
+
KeepFunctor &&keep,
|
| 251 |
+
ReduceFunctor &&reduce,
|
| 252 |
+
InitialValueType &&initialValue,
|
| 253 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 254 |
+
| SequentialReduce))
|
| 255 |
+
{
|
| 256 |
+
return startFilteredReduced<ResultType>(
|
| 257 |
+
QThreadPool::globalInstance(), begin, end, std::forward<KeepFunctor>(keep),
|
| 258 |
+
std::forward<ReduceFunctor>(reduce),
|
| 259 |
+
ResultType(std::forward<InitialValueType>(initialValue)), options);
|
| 260 |
+
}
|
| 261 |
+
|
| 262 |
+
#ifndef Q_QDOC
|
| 263 |
+
template <typename Iterator, typename KeepFunctor, typename ReduceFunctor,
|
| 264 |
+
typename ResultType = typename QtPrivate::ReduceResultTypeHelper<ReduceFunctor>::type>
|
| 265 |
+
QFuture<ResultType> filteredReduced(QThreadPool *pool,
|
| 266 |
+
Iterator begin,
|
| 267 |
+
Iterator end,
|
| 268 |
+
KeepFunctor &&keep,
|
| 269 |
+
ReduceFunctor &&reduce,
|
| 270 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 271 |
+
| SequentialReduce))
|
| 272 |
+
{
|
| 273 |
+
return startFilteredReduced<ResultType>(pool, begin, end, std::forward<KeepFunctor>(keep),
|
| 274 |
+
std::forward<ReduceFunctor>(reduce), options);
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
template <typename Iterator, typename KeepFunctor, typename ReduceFunctor,
|
| 278 |
+
typename ResultType = typename QtPrivate::ReduceResultTypeHelper<ReduceFunctor>::type>
|
| 279 |
+
QFuture<ResultType> filteredReduced(Iterator begin,
|
| 280 |
+
Iterator end,
|
| 281 |
+
KeepFunctor &&keep,
|
| 282 |
+
ReduceFunctor &&reduce,
|
| 283 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 284 |
+
| SequentialReduce))
|
| 285 |
+
{
|
| 286 |
+
return startFilteredReduced<ResultType>(QThreadPool::globalInstance(), begin, end,
|
| 287 |
+
std::forward<KeepFunctor>(keep),
|
| 288 |
+
std::forward<ReduceFunctor>(reduce), options);
|
| 289 |
+
}
|
| 290 |
+
|
| 291 |
+
template <typename Iterator, typename KeepFunctor, typename ReduceFunctor,
|
| 292 |
+
typename ResultType = typename QtPrivate::ReduceResultTypeHelper<ReduceFunctor>::type,
|
| 293 |
+
typename InitialValueType,
|
| 294 |
+
std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
|
| 295 |
+
int> = 0>
|
| 296 |
+
QFuture<ResultType> filteredReduced(QThreadPool *pool,
|
| 297 |
+
Iterator begin,
|
| 298 |
+
Iterator end,
|
| 299 |
+
KeepFunctor &&keep,
|
| 300 |
+
ReduceFunctor &&reduce,
|
| 301 |
+
InitialValueType &&initialValue,
|
| 302 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 303 |
+
| SequentialReduce))
|
| 304 |
+
{
|
| 305 |
+
return startFilteredReduced<ResultType>(
|
| 306 |
+
pool, begin, end, std::forward<KeepFunctor>(keep), std::forward<ReduceFunctor>(reduce),
|
| 307 |
+
ResultType(std::forward<InitialValueType>(initialValue)), options);
|
| 308 |
+
}
|
| 309 |
+
|
| 310 |
+
template <typename Iterator, typename KeepFunctor, typename ReduceFunctor,
|
| 311 |
+
std::enable_if_t<QtPrivate::isIterator_v<Iterator>, int> = 0,
|
| 312 |
+
typename ResultType = typename QtPrivate::ReduceResultTypeHelper<ReduceFunctor>::type,
|
| 313 |
+
typename InitialValueType,
|
| 314 |
+
std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
|
| 315 |
+
int> = 0>
|
| 316 |
+
QFuture<ResultType> filteredReduced(Iterator begin,
|
| 317 |
+
Iterator end,
|
| 318 |
+
KeepFunctor &&keep,
|
| 319 |
+
ReduceFunctor &&reduce,
|
| 320 |
+
InitialValueType &&initialValue,
|
| 321 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 322 |
+
| SequentialReduce))
|
| 323 |
+
{
|
| 324 |
+
return startFilteredReduced<ResultType>(
|
| 325 |
+
QThreadPool::globalInstance(), begin, end, std::forward<KeepFunctor>(keep),
|
| 326 |
+
std::forward<ReduceFunctor>(reduce),
|
| 327 |
+
ResultType(std::forward<InitialValueType>(initialValue)), options);
|
| 328 |
+
}
|
| 329 |
+
#endif
|
| 330 |
+
|
| 331 |
+
// filtered() on sequences
|
| 332 |
+
template <typename Sequence, typename KeepFunctor>
|
| 333 |
+
QFuture<typename std::decay_t<Sequence>::value_type> filtered(QThreadPool *pool,Sequence &&sequence,
|
| 334 |
+
KeepFunctor &&keep)
|
| 335 |
+
{
|
| 336 |
+
return startFiltered(pool, std::forward<Sequence>(sequence), std::forward<KeepFunctor>(keep));
|
| 337 |
+
}
|
| 338 |
+
|
| 339 |
+
template <typename Sequence, typename KeepFunctor>
|
| 340 |
+
QFuture<typename std::decay_t<Sequence>::value_type> filtered(Sequence &&sequence,
|
| 341 |
+
KeepFunctor &&keep)
|
| 342 |
+
{
|
| 343 |
+
return startFiltered(QThreadPool::globalInstance(), std::forward<Sequence>(sequence),
|
| 344 |
+
std::forward<KeepFunctor>(keep));
|
| 345 |
+
}
|
| 346 |
+
|
| 347 |
+
// filtered() on iterators
|
| 348 |
+
template <typename Iterator, typename KeepFunctor>
|
| 349 |
+
QFuture<typename qValueType<Iterator>::value_type> filtered(QThreadPool *pool,
|
| 350 |
+
Iterator begin,
|
| 351 |
+
Iterator end,
|
| 352 |
+
KeepFunctor &&keep)
|
| 353 |
+
{
|
| 354 |
+
return startFiltered(pool, begin, end, std::forward<KeepFunctor>(keep));
|
| 355 |
+
}
|
| 356 |
+
|
| 357 |
+
template <typename Iterator, typename KeepFunctor>
|
| 358 |
+
QFuture<typename qValueType<Iterator>::value_type> filtered(Iterator begin,
|
| 359 |
+
Iterator end,
|
| 360 |
+
KeepFunctor &&keep)
|
| 361 |
+
{
|
| 362 |
+
return startFiltered(QThreadPool::globalInstance(), begin, end,
|
| 363 |
+
std::forward<KeepFunctor>(keep));
|
| 364 |
+
}
|
| 365 |
+
|
| 366 |
+
// blocking filter() on sequences
|
| 367 |
+
template <typename Sequence, typename KeepFunctor>
|
| 368 |
+
void blockingFilter(QThreadPool *pool, Sequence &sequence, KeepFunctor &&keep)
|
| 369 |
+
{
|
| 370 |
+
QFuture<void> future = filter(pool, sequence, std::forward<KeepFunctor>(keep));
|
| 371 |
+
future.waitForFinished();
|
| 372 |
+
}
|
| 373 |
+
|
| 374 |
+
template <typename Sequence, typename KeepFunctor>
|
| 375 |
+
void blockingFilter(Sequence &sequence, KeepFunctor &&keep)
|
| 376 |
+
{
|
| 377 |
+
QFuture<void> future = filter(sequence, std::forward<KeepFunctor>(keep));
|
| 378 |
+
future.waitForFinished();
|
| 379 |
+
}
|
| 380 |
+
|
| 381 |
+
// blocking filteredReduced() on sequences
|
| 382 |
+
template <typename ResultType, typename Sequence, typename KeepFunctor, typename ReduceFunctor>
|
| 383 |
+
ResultType blockingFilteredReduced(QThreadPool *pool,
|
| 384 |
+
Sequence &&sequence,
|
| 385 |
+
KeepFunctor &&keep,
|
| 386 |
+
ReduceFunctor &&reduce,
|
| 387 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 388 |
+
| SequentialReduce))
|
| 389 |
+
{
|
| 390 |
+
QFuture<ResultType> future = filteredReduced<ResultType>(
|
| 391 |
+
pool, std::forward<Sequence>(sequence), std::forward<KeepFunctor>(keep),
|
| 392 |
+
std::forward<ReduceFunctor>(reduce), options);
|
| 393 |
+
return future.takeResult();
|
| 394 |
+
}
|
| 395 |
+
|
| 396 |
+
template <typename ResultType, typename Sequence, typename KeepFunctor, typename ReduceFunctor>
|
| 397 |
+
ResultType blockingFilteredReduced(Sequence &&sequence,
|
| 398 |
+
KeepFunctor &&keep,
|
| 399 |
+
ReduceFunctor &&reduce,
|
| 400 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 401 |
+
| SequentialReduce))
|
| 402 |
+
{
|
| 403 |
+
QFuture<ResultType> future = filteredReduced<ResultType>(
|
| 404 |
+
std::forward<Sequence>(sequence), std::forward<KeepFunctor>(keep),
|
| 405 |
+
std::forward<ReduceFunctor>(reduce), options);
|
| 406 |
+
return future.takeResult();
|
| 407 |
+
}
|
| 408 |
+
|
| 409 |
+
#ifdef Q_QDOC
|
| 410 |
+
template <typename ResultType, typename Sequence, typename KeepFunctor, typename ReduceFunctor,
|
| 411 |
+
typename InitialValueType>
|
| 412 |
+
#else
|
| 413 |
+
template <typename ResultType, typename Sequence, typename KeepFunctor, typename ReduceFunctor,
|
| 414 |
+
typename InitialValueType,
|
| 415 |
+
std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
|
| 416 |
+
int> = 0>
|
| 417 |
+
#endif
|
| 418 |
+
ResultType blockingFilteredReduced(QThreadPool *pool,
|
| 419 |
+
Sequence &&sequence,
|
| 420 |
+
KeepFunctor &&keep,
|
| 421 |
+
ReduceFunctor &&reduce,
|
| 422 |
+
InitialValueType &&initialValue,
|
| 423 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 424 |
+
| SequentialReduce))
|
| 425 |
+
{
|
| 426 |
+
QFuture<ResultType> future = filteredReduced<ResultType>(
|
| 427 |
+
pool, std::forward<Sequence>(sequence), std::forward<KeepFunctor>(keep),
|
| 428 |
+
std::forward<ReduceFunctor>(reduce),
|
| 429 |
+
ResultType(std::forward<InitialValueType>(initialValue)), options);
|
| 430 |
+
return future.takeResult();
|
| 431 |
+
}
|
| 432 |
+
|
| 433 |
+
#ifdef Q_QDOC
|
| 434 |
+
template <typename ResultType, typename Sequence, typename KeepFunctor, typename ReduceFunctor,
|
| 435 |
+
typename InitialValueType>
|
| 436 |
+
#else
|
| 437 |
+
template <typename ResultType, typename Sequence, typename KeepFunctor, typename ReduceFunctor,
|
| 438 |
+
typename InitialValueType,
|
| 439 |
+
std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
|
| 440 |
+
int> = 0>
|
| 441 |
+
#endif
|
| 442 |
+
ResultType blockingFilteredReduced(Sequence &&sequence,
|
| 443 |
+
KeepFunctor &&keep,
|
| 444 |
+
ReduceFunctor &&reduce,
|
| 445 |
+
InitialValueType &&initialValue,
|
| 446 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 447 |
+
| SequentialReduce))
|
| 448 |
+
{
|
| 449 |
+
QFuture<ResultType> future = filteredReduced<ResultType>(
|
| 450 |
+
std::forward<Sequence>(sequence), std::forward<KeepFunctor>(keep),
|
| 451 |
+
std::forward<ReduceFunctor>(reduce),
|
| 452 |
+
ResultType(std::forward<InitialValueType>(initialValue)), options);
|
| 453 |
+
return future.takeResult();
|
| 454 |
+
}
|
| 455 |
+
|
| 456 |
+
#ifndef Q_QDOC
|
| 457 |
+
template <typename Sequence, typename KeepFunctor, typename ReduceFunctor,
|
| 458 |
+
std::enable_if_t<QtPrivate::isInvocable<KeepFunctor, Sequence>::value, int> = 0,
|
| 459 |
+
typename ResultType = typename QtPrivate::ReduceResultTypeHelper<ReduceFunctor>::type>
|
| 460 |
+
ResultType blockingFilteredReduced(QThreadPool *pool,
|
| 461 |
+
Sequence &&sequence,
|
| 462 |
+
KeepFunctor &&keep,
|
| 463 |
+
ReduceFunctor &&reduce,
|
| 464 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 465 |
+
| SequentialReduce))
|
| 466 |
+
{
|
| 467 |
+
QFuture<ResultType> future = filteredReduced<ResultType>(
|
| 468 |
+
pool, std::forward<Sequence>(sequence), std::forward<KeepFunctor>(keep),
|
| 469 |
+
std::forward<ReduceFunctor>(reduce), options);
|
| 470 |
+
return future.takeResult();
|
| 471 |
+
}
|
| 472 |
+
|
| 473 |
+
template <typename Sequence, typename KeepFunctor, typename ReduceFunctor,
|
| 474 |
+
std::enable_if_t<QtPrivate::isInvocable<KeepFunctor, Sequence>::value, int> = 0,
|
| 475 |
+
typename ResultType = typename QtPrivate::ReduceResultTypeHelper<ReduceFunctor>::type>
|
| 476 |
+
ResultType blockingFilteredReduced(Sequence &&sequence,
|
| 477 |
+
KeepFunctor &&keep,
|
| 478 |
+
ReduceFunctor &&reduce,
|
| 479 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 480 |
+
| SequentialReduce))
|
| 481 |
+
{
|
| 482 |
+
QFuture<ResultType> future = filteredReduced<ResultType>(
|
| 483 |
+
std::forward<Sequence>(sequence), std::forward<KeepFunctor>(keep),
|
| 484 |
+
std::forward<ReduceFunctor>(reduce), options);
|
| 485 |
+
return future.takeResult();
|
| 486 |
+
}
|
| 487 |
+
|
| 488 |
+
template <typename Sequence, typename KeepFunctor, typename ReduceFunctor,
|
| 489 |
+
typename InitialValueType,
|
| 490 |
+
std::enable_if_t<QtPrivate::isInvocable<KeepFunctor, Sequence>::value, int> = 0,
|
| 491 |
+
typename ResultType = typename QtPrivate::ReduceResultTypeHelper<ReduceFunctor>::type,
|
| 492 |
+
std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
|
| 493 |
+
int> = 0>
|
| 494 |
+
ResultType blockingFilteredReduced(QThreadPool *pool,
|
| 495 |
+
Sequence &&sequence,
|
| 496 |
+
KeepFunctor &&keep,
|
| 497 |
+
ReduceFunctor &&reduce,
|
| 498 |
+
InitialValueType &&initialValue,
|
| 499 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 500 |
+
| SequentialReduce))
|
| 501 |
+
{
|
| 502 |
+
QFuture<ResultType> future = filteredReduced<ResultType>(
|
| 503 |
+
pool, std::forward<Sequence>(sequence), std::forward<KeepFunctor>(keep),
|
| 504 |
+
std::forward<ReduceFunctor>(reduce),
|
| 505 |
+
ResultType(std::forward<InitialValueType>(initialValue)), options);
|
| 506 |
+
return future.takeResult();
|
| 507 |
+
}
|
| 508 |
+
|
| 509 |
+
template <typename Sequence, typename KeepFunctor, typename ReduceFunctor,
|
| 510 |
+
typename InitialValueType,
|
| 511 |
+
std::enable_if_t<QtPrivate::isInvocable<KeepFunctor, Sequence>::value, int> = 0,
|
| 512 |
+
typename ResultType = typename QtPrivate::ReduceResultTypeHelper<ReduceFunctor>::type,
|
| 513 |
+
std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
|
| 514 |
+
int> = 0>
|
| 515 |
+
ResultType blockingFilteredReduced(Sequence &&sequence,
|
| 516 |
+
KeepFunctor &&keep,
|
| 517 |
+
ReduceFunctor &&reduce,
|
| 518 |
+
InitialValueType &&initialValue,
|
| 519 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 520 |
+
| SequentialReduce))
|
| 521 |
+
{
|
| 522 |
+
QFuture<ResultType> future = filteredReduced<ResultType>(
|
| 523 |
+
std::forward<Sequence>(sequence), std::forward<KeepFunctor>(keep),
|
| 524 |
+
std::forward<ReduceFunctor>(reduce),
|
| 525 |
+
ResultType(std::forward<InitialValueType>(initialValue)), options);
|
| 526 |
+
return future.takeResult();
|
| 527 |
+
}
|
| 528 |
+
#endif
|
| 529 |
+
|
| 530 |
+
// blocking filteredReduced() on iterators
|
| 531 |
+
template <typename ResultType, typename Iterator, typename KeepFunctor, typename ReduceFunctor>
|
| 532 |
+
ResultType blockingFilteredReduced(QThreadPool *pool,
|
| 533 |
+
Iterator begin,
|
| 534 |
+
Iterator end,
|
| 535 |
+
KeepFunctor &&keep,
|
| 536 |
+
ReduceFunctor &&reduce,
|
| 537 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 538 |
+
| SequentialReduce))
|
| 539 |
+
{
|
| 540 |
+
QFuture<ResultType> future =
|
| 541 |
+
filteredReduced<ResultType>(pool, begin, end, std::forward<KeepFunctor>(keep),
|
| 542 |
+
std::forward<ReduceFunctor>(reduce), options);
|
| 543 |
+
return future.takeResult();
|
| 544 |
+
}
|
| 545 |
+
|
| 546 |
+
template <typename ResultType, typename Iterator, typename KeepFunctor, typename ReduceFunctor>
|
| 547 |
+
ResultType blockingFilteredReduced(Iterator begin,
|
| 548 |
+
Iterator end,
|
| 549 |
+
KeepFunctor &&keep,
|
| 550 |
+
ReduceFunctor &&reduce,
|
| 551 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 552 |
+
| SequentialReduce))
|
| 553 |
+
{
|
| 554 |
+
QFuture<ResultType> future =
|
| 555 |
+
filteredReduced<ResultType>(begin, end, std::forward<KeepFunctor>(keep),
|
| 556 |
+
std::forward<ReduceFunctor>(reduce), options);
|
| 557 |
+
return future.takeResult();
|
| 558 |
+
}
|
| 559 |
+
|
| 560 |
+
#ifdef Q_QDOC
|
| 561 |
+
template <typename ResultType, typename Iterator, typename KeepFunctor, typename ReduceFunctor,
|
| 562 |
+
typename InitialValueType>
|
| 563 |
+
#else
|
| 564 |
+
template <typename ResultType, typename Iterator, typename KeepFunctor, typename ReduceFunctor,
|
| 565 |
+
typename InitialValueType,
|
| 566 |
+
std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
|
| 567 |
+
int> = 0>
|
| 568 |
+
#endif
|
| 569 |
+
ResultType blockingFilteredReduced(QThreadPool *pool,
|
| 570 |
+
Iterator begin,
|
| 571 |
+
Iterator end,
|
| 572 |
+
KeepFunctor &&keep,
|
| 573 |
+
ReduceFunctor &&reduce,
|
| 574 |
+
InitialValueType &&initialValue,
|
| 575 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 576 |
+
| SequentialReduce))
|
| 577 |
+
{
|
| 578 |
+
QFuture<ResultType> future = filteredReduced<ResultType>(
|
| 579 |
+
pool, begin, end, std::forward<KeepFunctor>(keep), std::forward<ReduceFunctor>(reduce),
|
| 580 |
+
ResultType(std::forward<InitialValueType>(initialValue)), options);
|
| 581 |
+
return future.takeResult();
|
| 582 |
+
}
|
| 583 |
+
|
| 584 |
+
#ifdef Q_QDOC
|
| 585 |
+
template <typename ResultType, typename Iterator, typename KeepFunctor, typename ReduceFunctor,
|
| 586 |
+
typename InitialValueType>
|
| 587 |
+
#else
|
| 588 |
+
template <typename ResultType, typename Iterator, typename KeepFunctor, typename ReduceFunctor,
|
| 589 |
+
typename InitialValueType,
|
| 590 |
+
std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
|
| 591 |
+
int> = 0>
|
| 592 |
+
#endif
|
| 593 |
+
ResultType blockingFilteredReduced(Iterator begin,
|
| 594 |
+
Iterator end,
|
| 595 |
+
KeepFunctor &&keep,
|
| 596 |
+
ReduceFunctor &&reduce,
|
| 597 |
+
InitialValueType &&initialValue,
|
| 598 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 599 |
+
| SequentialReduce))
|
| 600 |
+
{
|
| 601 |
+
QFuture<ResultType> future = filteredReduced<ResultType>(
|
| 602 |
+
begin, end, std::forward<KeepFunctor>(keep), std::forward<ReduceFunctor>(reduce),
|
| 603 |
+
ResultType(std::forward<InitialValueType>(initialValue)), options);
|
| 604 |
+
return future.takeResult();
|
| 605 |
+
}
|
| 606 |
+
|
| 607 |
+
#ifndef Q_QDOC
|
| 608 |
+
template <typename Iterator, typename KeepFunctor, typename ReduceFunctor,
|
| 609 |
+
typename ResultType = typename QtPrivate::ReduceResultTypeHelper<ReduceFunctor>::type>
|
| 610 |
+
ResultType blockingFilteredReduced(QThreadPool *pool,
|
| 611 |
+
Iterator begin,
|
| 612 |
+
Iterator end,
|
| 613 |
+
KeepFunctor &&keep,
|
| 614 |
+
ReduceFunctor &&reduce,
|
| 615 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 616 |
+
| SequentialReduce))
|
| 617 |
+
{
|
| 618 |
+
QFuture<ResultType> future =
|
| 619 |
+
filteredReduced<ResultType>(pool, begin, end, std::forward<KeepFunctor>(keep),
|
| 620 |
+
std::forward<ReduceFunctor>(reduce), options);
|
| 621 |
+
return future.takeResult();
|
| 622 |
+
}
|
| 623 |
+
|
| 624 |
+
template <typename Iterator, typename KeepFunctor, typename ReduceFunctor,
|
| 625 |
+
typename ResultType = typename QtPrivate::ReduceResultTypeHelper<ReduceFunctor>::type>
|
| 626 |
+
ResultType blockingFilteredReduced(Iterator begin,
|
| 627 |
+
Iterator end,
|
| 628 |
+
KeepFunctor &&keep,
|
| 629 |
+
ReduceFunctor &&reduce,
|
| 630 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 631 |
+
| SequentialReduce))
|
| 632 |
+
{
|
| 633 |
+
QFuture<ResultType> future =
|
| 634 |
+
filteredReduced<ResultType>(begin, end, std::forward<KeepFunctor>(keep),
|
| 635 |
+
std::forward<ReduceFunctor>(reduce), options);
|
| 636 |
+
return future.takeResult();
|
| 637 |
+
}
|
| 638 |
+
|
| 639 |
+
template <typename Iterator, typename KeepFunctor, typename ReduceFunctor,
|
| 640 |
+
typename ResultType = typename QtPrivate::ReduceResultTypeHelper<ReduceFunctor>::type,
|
| 641 |
+
typename InitialValueType,
|
| 642 |
+
std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
|
| 643 |
+
int> = 0>
|
| 644 |
+
ResultType blockingFilteredReduced(QThreadPool *pool,
|
| 645 |
+
Iterator begin,
|
| 646 |
+
Iterator end, KeepFunctor &&keep,
|
| 647 |
+
ReduceFunctor &&reduce,
|
| 648 |
+
InitialValueType &&initialValue,
|
| 649 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 650 |
+
| SequentialReduce))
|
| 651 |
+
{
|
| 652 |
+
QFuture<ResultType> future = filteredReduced<ResultType>(
|
| 653 |
+
pool, begin, end, std::forward<KeepFunctor>(keep), std::forward<ReduceFunctor>(reduce),
|
| 654 |
+
ResultType(std::forward<InitialValueType>(initialValue)), options);
|
| 655 |
+
return future.takeResult();
|
| 656 |
+
}
|
| 657 |
+
|
| 658 |
+
template <typename Iterator, typename KeepFunctor, typename ReduceFunctor,
|
| 659 |
+
std::enable_if_t<QtPrivate::isIterator_v<Iterator>, int> = 0,
|
| 660 |
+
typename ResultType = typename QtPrivate::ReduceResultTypeHelper<ReduceFunctor>::type,
|
| 661 |
+
typename InitialValueType,
|
| 662 |
+
std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
|
| 663 |
+
int> = 0>
|
| 664 |
+
ResultType blockingFilteredReduced(Iterator begin,
|
| 665 |
+
Iterator end,
|
| 666 |
+
KeepFunctor &&keep,
|
| 667 |
+
ReduceFunctor &&reduce,
|
| 668 |
+
InitialValueType &&initialValue,
|
| 669 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 670 |
+
| SequentialReduce))
|
| 671 |
+
{
|
| 672 |
+
QFuture<ResultType> future = filteredReduced<ResultType>(
|
| 673 |
+
begin, end, std::forward<KeepFunctor>(keep), std::forward<ReduceFunctor>(reduce),
|
| 674 |
+
ResultType(std::forward<InitialValueType>(initialValue)), options);
|
| 675 |
+
return future.takeResult();
|
| 676 |
+
}
|
| 677 |
+
#endif
|
| 678 |
+
|
| 679 |
+
// blocking filtered() on sequences
|
| 680 |
+
template <typename Sequence, typename KeepFunctor>
|
| 681 |
+
std::decay_t<Sequence> blockingFiltered(QThreadPool *pool, Sequence &&sequence, KeepFunctor &&keep)
|
| 682 |
+
{
|
| 683 |
+
return blockingFilteredReduced<std::decay_t<Sequence>>(
|
| 684 |
+
pool, std::forward<Sequence>(sequence), std::forward<KeepFunctor>(keep),
|
| 685 |
+
QtPrivate::PushBackWrapper(), OrderedReduce);
|
| 686 |
+
}
|
| 687 |
+
|
| 688 |
+
template <typename Sequence, typename KeepFunctor>
|
| 689 |
+
std::decay_t<Sequence> blockingFiltered(Sequence &&sequence, KeepFunctor &&keep)
|
| 690 |
+
{
|
| 691 |
+
return blockingFilteredReduced<std::decay_t<Sequence>>(
|
| 692 |
+
QThreadPool::globalInstance(), std::forward<Sequence>(sequence),
|
| 693 |
+
std::forward<KeepFunctor>(keep), QtPrivate::PushBackWrapper(), OrderedReduce);
|
| 694 |
+
}
|
| 695 |
+
|
| 696 |
+
// blocking filtered() on iterators
|
| 697 |
+
template <typename OutputSequence, typename Iterator, typename KeepFunctor>
|
| 698 |
+
OutputSequence blockingFiltered(QThreadPool *pool, Iterator begin, Iterator end, KeepFunctor &&keep)
|
| 699 |
+
{
|
| 700 |
+
return blockingFilteredReduced<OutputSequence>(pool, begin, end,
|
| 701 |
+
std::forward<KeepFunctor>(keep),
|
| 702 |
+
QtPrivate::PushBackWrapper(), OrderedReduce);
|
| 703 |
+
}
|
| 704 |
+
|
| 705 |
+
template <typename OutputSequence, typename Iterator, typename KeepFunctor>
|
| 706 |
+
OutputSequence blockingFiltered(Iterator begin, Iterator end, KeepFunctor &&keep)
|
| 707 |
+
{
|
| 708 |
+
return blockingFilteredReduced<OutputSequence>(QThreadPool::globalInstance(), begin, end,
|
| 709 |
+
std::forward<KeepFunctor>(keep),
|
| 710 |
+
QtPrivate::PushBackWrapper(), OrderedReduce);
|
| 711 |
+
}
|
| 712 |
+
|
| 713 |
+
} // namespace QtConcurrent
|
| 714 |
+
|
| 715 |
+
QT_END_NAMESPACE
|
| 716 |
+
|
| 717 |
+
#endif // QT_NO_CONCURRENT
|
| 718 |
+
|
| 719 |
+
#endif
|
qt/6.8.1/msvc2022_64/include/QtConcurrent/qtconcurrentfilterkernel.h
ADDED
|
@@ -0,0 +1,386 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright (C) 2016 The Qt Company Ltd.
|
| 2 |
+
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
| 3 |
+
|
| 4 |
+
#ifndef QTCONCURRENT_FILTERKERNEL_H
|
| 5 |
+
#define QTCONCURRENT_FILTERKERNEL_H
|
| 6 |
+
|
| 7 |
+
#include <QtConcurrent/qtconcurrent_global.h>
|
| 8 |
+
|
| 9 |
+
#if !defined(QT_NO_CONCURRENT) || defined (Q_QDOC)
|
| 10 |
+
|
| 11 |
+
#include <QtConcurrent/qtconcurrentiteratekernel.h>
|
| 12 |
+
#include <QtConcurrent/qtconcurrentmapkernel.h>
|
| 13 |
+
#include <QtConcurrent/qtconcurrentreducekernel.h>
|
| 14 |
+
|
| 15 |
+
QT_BEGIN_NAMESPACE
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
namespace QtConcurrent {
|
| 20 |
+
|
| 21 |
+
template <typename T>
|
| 22 |
+
struct qValueType
|
| 23 |
+
{
|
| 24 |
+
typedef typename T::value_type value_type;
|
| 25 |
+
};
|
| 26 |
+
|
| 27 |
+
template <typename T>
|
| 28 |
+
struct qValueType<const T*>
|
| 29 |
+
{
|
| 30 |
+
typedef T value_type;
|
| 31 |
+
};
|
| 32 |
+
|
| 33 |
+
template <typename T>
|
| 34 |
+
struct qValueType<T*>
|
| 35 |
+
{
|
| 36 |
+
typedef T value_type;
|
| 37 |
+
};
|
| 38 |
+
|
| 39 |
+
// Implementation of filter
|
| 40 |
+
template <typename Sequence, typename KeepFunctor, typename ReduceFunctor>
|
| 41 |
+
class FilterKernel : public IterateKernel<typename Sequence::const_iterator, void>
|
| 42 |
+
{
|
| 43 |
+
typedef ReduceKernel<ReduceFunctor, Sequence, typename Sequence::value_type> Reducer;
|
| 44 |
+
typedef IterateKernel<typename Sequence::const_iterator, void> IterateKernelType;
|
| 45 |
+
typedef void T;
|
| 46 |
+
|
| 47 |
+
Sequence reducedResult;
|
| 48 |
+
Sequence &sequence;
|
| 49 |
+
KeepFunctor keep;
|
| 50 |
+
ReduceFunctor reduce;
|
| 51 |
+
Reducer reducer;
|
| 52 |
+
|
| 53 |
+
public:
|
| 54 |
+
template <typename Keep = KeepFunctor, typename Reduce = ReduceFunctor>
|
| 55 |
+
FilterKernel(QThreadPool *pool, Sequence &_sequence, Keep &&_keep, Reduce &&_reduce)
|
| 56 |
+
: IterateKernelType(pool, const_cast<const Sequence &>(_sequence).begin(),
|
| 57 |
+
const_cast<const Sequence &>(_sequence).end()), reducedResult(),
|
| 58 |
+
sequence(_sequence),
|
| 59 |
+
keep(std::forward<Keep>(_keep)),
|
| 60 |
+
reduce(std::forward<Reduce>(_reduce)),
|
| 61 |
+
reducer(pool, OrderedReduce)
|
| 62 |
+
{ }
|
| 63 |
+
|
| 64 |
+
bool runIteration(typename Sequence::const_iterator it, int index, T *) override
|
| 65 |
+
{
|
| 66 |
+
IntermediateResults<typename Sequence::value_type> results;
|
| 67 |
+
results.begin = index;
|
| 68 |
+
results.end = index + 1;
|
| 69 |
+
|
| 70 |
+
if (std::invoke(keep, *it))
|
| 71 |
+
results.vector.append(*it);
|
| 72 |
+
|
| 73 |
+
reducer.runReduce(reduce, reducedResult, results);
|
| 74 |
+
return false;
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
bool runIterations(typename Sequence::const_iterator sequenceBeginIterator, int begin, int end, T *) override
|
| 78 |
+
{
|
| 79 |
+
IntermediateResults<typename Sequence::value_type> results;
|
| 80 |
+
results.begin = begin;
|
| 81 |
+
results.end = end;
|
| 82 |
+
results.vector.reserve(end - begin);
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
typename Sequence::const_iterator it = sequenceBeginIterator;
|
| 86 |
+
std::advance(it, begin);
|
| 87 |
+
for (int i = begin; i < end; ++i) {
|
| 88 |
+
if (std::invoke(keep, *it))
|
| 89 |
+
results.vector.append(*it);
|
| 90 |
+
std::advance(it, 1);
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
reducer.runReduce(reduce, reducedResult, results);
|
| 94 |
+
return false;
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
void finish() override
|
| 98 |
+
{
|
| 99 |
+
reducer.finish(reduce, reducedResult);
|
| 100 |
+
sequence = std::move(reducedResult);
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
inline bool shouldThrottleThread() override
|
| 104 |
+
{
|
| 105 |
+
return IterateKernelType::shouldThrottleThread() || reducer.shouldThrottle();
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
inline bool shouldStartThread() override
|
| 109 |
+
{
|
| 110 |
+
return IterateKernelType::shouldStartThread() && reducer.shouldStartThread();
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
typedef void ReturnType;
|
| 114 |
+
typedef void ResultType;
|
| 115 |
+
};
|
| 116 |
+
|
| 117 |
+
// Implementation of filter-reduce
|
| 118 |
+
template <typename ReducedResultType,
|
| 119 |
+
typename Iterator,
|
| 120 |
+
typename KeepFunctor,
|
| 121 |
+
typename ReduceFunctor,
|
| 122 |
+
typename Reducer = ReduceKernel<ReduceFunctor,
|
| 123 |
+
ReducedResultType,
|
| 124 |
+
typename qValueType<Iterator>::value_type> >
|
| 125 |
+
class FilteredReducedKernel : public IterateKernel<Iterator, ReducedResultType>
|
| 126 |
+
{
|
| 127 |
+
ReducedResultType &reducedResult;
|
| 128 |
+
KeepFunctor keep;
|
| 129 |
+
ReduceFunctor reduce;
|
| 130 |
+
Reducer reducer;
|
| 131 |
+
typedef IterateKernel<Iterator, ReducedResultType> IterateKernelType;
|
| 132 |
+
|
| 133 |
+
public:
|
| 134 |
+
template<typename Keep = KeepFunctor, typename Reduce = ReduceFunctor>
|
| 135 |
+
FilteredReducedKernel(QThreadPool *pool, Iterator begin, Iterator end, Keep &&_keep,
|
| 136 |
+
Reduce &&_reduce, ReduceOptions reduceOption)
|
| 137 |
+
: IterateKernelType(pool, begin, end),
|
| 138 |
+
reducedResult(this->defaultValue.value),
|
| 139 |
+
keep(std::forward<Keep>(_keep)),
|
| 140 |
+
reduce(std::forward<Reduce>(_reduce)),
|
| 141 |
+
reducer(pool, reduceOption)
|
| 142 |
+
{ }
|
| 143 |
+
|
| 144 |
+
template <typename Keep = KeepFunctor, typename Reduce = ReduceFunctor>
|
| 145 |
+
FilteredReducedKernel(QThreadPool *pool, Iterator begin, Iterator end, Keep &&_keep,
|
| 146 |
+
Reduce &&_reduce, ReducedResultType &&initialValue,
|
| 147 |
+
ReduceOptions reduceOption)
|
| 148 |
+
: IterateKernelType(pool, begin, end, std::forward<ReducedResultType>(initialValue)),
|
| 149 |
+
reducedResult(this->defaultValue.value),
|
| 150 |
+
keep(std::forward<Keep>(_keep)),
|
| 151 |
+
reduce(std::forward<Reduce>(_reduce)),
|
| 152 |
+
reducer(pool, reduceOption)
|
| 153 |
+
{
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
bool runIteration(Iterator it, int index, ReducedResultType *) override
|
| 157 |
+
{
|
| 158 |
+
IntermediateResults<typename qValueType<Iterator>::value_type> results;
|
| 159 |
+
results.begin = index;
|
| 160 |
+
results.end = index + 1;
|
| 161 |
+
|
| 162 |
+
if (std::invoke(keep, *it))
|
| 163 |
+
results.vector.append(*it);
|
| 164 |
+
|
| 165 |
+
reducer.runReduce(reduce, reducedResult, results);
|
| 166 |
+
return false;
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
bool runIterations(Iterator sequenceBeginIterator, int begin, int end, ReducedResultType *) override
|
| 170 |
+
{
|
| 171 |
+
IntermediateResults<typename qValueType<Iterator>::value_type> results;
|
| 172 |
+
results.begin = begin;
|
| 173 |
+
results.end = end;
|
| 174 |
+
results.vector.reserve(end - begin);
|
| 175 |
+
|
| 176 |
+
Iterator it = sequenceBeginIterator;
|
| 177 |
+
std::advance(it, begin);
|
| 178 |
+
for (int i = begin; i < end; ++i) {
|
| 179 |
+
if (std::invoke(keep, *it))
|
| 180 |
+
results.vector.append(*it);
|
| 181 |
+
std::advance(it, 1);
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
reducer.runReduce(reduce, reducedResult, results);
|
| 185 |
+
return false;
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
void finish() override
|
| 189 |
+
{
|
| 190 |
+
reducer.finish(reduce, reducedResult);
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
inline bool shouldThrottleThread() override
|
| 194 |
+
{
|
| 195 |
+
return IterateKernelType::shouldThrottleThread() || reducer.shouldThrottle();
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
inline bool shouldStartThread() override
|
| 199 |
+
{
|
| 200 |
+
return IterateKernelType::shouldStartThread() && reducer.shouldStartThread();
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
typedef ReducedResultType ReturnType;
|
| 204 |
+
typedef ReducedResultType ResultType;
|
| 205 |
+
ReducedResultType *result() override
|
| 206 |
+
{
|
| 207 |
+
return &reducedResult;
|
| 208 |
+
}
|
| 209 |
+
};
|
| 210 |
+
|
| 211 |
+
// Implementation of filter that reports individual results via QFutureInterface
|
| 212 |
+
template <typename Iterator, typename KeepFunctor>
|
| 213 |
+
class FilteredEachKernel : public IterateKernel<Iterator, typename qValueType<Iterator>::value_type>
|
| 214 |
+
{
|
| 215 |
+
typedef typename qValueType<Iterator>::value_type T;
|
| 216 |
+
typedef IterateKernel<Iterator, T> IterateKernelType;
|
| 217 |
+
|
| 218 |
+
KeepFunctor keep;
|
| 219 |
+
|
| 220 |
+
public:
|
| 221 |
+
typedef T ReturnType;
|
| 222 |
+
typedef T ResultType;
|
| 223 |
+
|
| 224 |
+
template <typename Keep = KeepFunctor>
|
| 225 |
+
FilteredEachKernel(QThreadPool *pool, Iterator begin, Iterator end, Keep &&_keep)
|
| 226 |
+
: IterateKernelType(pool, begin, end), keep(std::forward<Keep>(_keep))
|
| 227 |
+
{ }
|
| 228 |
+
|
| 229 |
+
void start() override
|
| 230 |
+
{
|
| 231 |
+
if (this->futureInterface)
|
| 232 |
+
this->futureInterface->setFilterMode(true);
|
| 233 |
+
IterateKernelType::start();
|
| 234 |
+
}
|
| 235 |
+
|
| 236 |
+
bool runIteration(Iterator it, int index, T *) override
|
| 237 |
+
{
|
| 238 |
+
if (std::invoke(keep, *it))
|
| 239 |
+
this->reportResult(&(*it), index);
|
| 240 |
+
else
|
| 241 |
+
this->reportResult(nullptr, index);
|
| 242 |
+
return false;
|
| 243 |
+
}
|
| 244 |
+
|
| 245 |
+
bool runIterations(Iterator sequenceBeginIterator, int begin, int end, T *) override
|
| 246 |
+
{
|
| 247 |
+
const int count = end - begin;
|
| 248 |
+
IntermediateResults<typename qValueType<Iterator>::value_type> results;
|
| 249 |
+
results.begin = begin;
|
| 250 |
+
results.end = end;
|
| 251 |
+
results.vector.reserve(count);
|
| 252 |
+
|
| 253 |
+
Iterator it = sequenceBeginIterator;
|
| 254 |
+
std::advance(it, begin);
|
| 255 |
+
for (int i = begin; i < end; ++i) {
|
| 256 |
+
if (std::invoke(keep, *it))
|
| 257 |
+
results.vector.append(*it);
|
| 258 |
+
std::advance(it, 1);
|
| 259 |
+
}
|
| 260 |
+
|
| 261 |
+
this->reportResults(results.vector, begin, count);
|
| 262 |
+
return false;
|
| 263 |
+
}
|
| 264 |
+
};
|
| 265 |
+
|
| 266 |
+
//! [QtConcurrent-2]
|
| 267 |
+
template <typename Iterator, typename KeepFunctor>
|
| 268 |
+
inline
|
| 269 |
+
ThreadEngineStarter<typename qValueType<Iterator>::value_type>
|
| 270 |
+
startFiltered(QThreadPool *pool, Iterator begin, Iterator end, KeepFunctor &&functor)
|
| 271 |
+
{
|
| 272 |
+
return startThreadEngine(new FilteredEachKernel<Iterator, std::decay_t<KeepFunctor>>
|
| 273 |
+
(pool, begin, end, std::forward<KeepFunctor>(functor)));
|
| 274 |
+
}
|
| 275 |
+
|
| 276 |
+
//! [QtConcurrent-3]
|
| 277 |
+
template <typename Sequence, typename KeepFunctor>
|
| 278 |
+
inline decltype(auto) startFiltered(QThreadPool *pool, Sequence &&sequence, KeepFunctor &&functor)
|
| 279 |
+
{
|
| 280 |
+
using DecayedSequence = std::decay_t<Sequence>;
|
| 281 |
+
using DecayedFunctor = std::decay_t<KeepFunctor>;
|
| 282 |
+
using SequenceHolderType = SequenceHolder1<DecayedSequence,
|
| 283 |
+
FilteredEachKernel<typename DecayedSequence::const_iterator, DecayedFunctor>,
|
| 284 |
+
DecayedFunctor>;
|
| 285 |
+
return startThreadEngine(new SequenceHolderType(pool, std::forward<Sequence>(sequence),
|
| 286 |
+
std::forward<KeepFunctor>(functor)));
|
| 287 |
+
}
|
| 288 |
+
|
| 289 |
+
//! [QtConcurrent-4]
|
| 290 |
+
template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor>
|
| 291 |
+
inline ThreadEngineStarter<ResultType> startFilteredReduced(QThreadPool *pool,
|
| 292 |
+
Sequence &&sequence,
|
| 293 |
+
MapFunctor &&mapFunctor,
|
| 294 |
+
ReduceFunctor &&reduceFunctor,
|
| 295 |
+
ReduceOptions options)
|
| 296 |
+
{
|
| 297 |
+
using DecayedSequence = std::decay_t<Sequence>;
|
| 298 |
+
using DecayedMapFunctor = std::decay_t<MapFunctor>;
|
| 299 |
+
using DecayedReduceFunctor = std::decay_t<ReduceFunctor>;
|
| 300 |
+
using Iterator = typename DecayedSequence::const_iterator;
|
| 301 |
+
using Reducer = ReduceKernel<DecayedReduceFunctor, ResultType,
|
| 302 |
+
typename qValueType<Iterator>::value_type>;
|
| 303 |
+
using FilteredReduceType = FilteredReducedKernel<ResultType, Iterator, DecayedMapFunctor,
|
| 304 |
+
DecayedReduceFunctor, Reducer>;
|
| 305 |
+
using SequenceHolderType = SequenceHolder2<DecayedSequence, FilteredReduceType,
|
| 306 |
+
DecayedMapFunctor, DecayedReduceFunctor>;
|
| 307 |
+
return startThreadEngine(new SequenceHolderType(pool, std::forward<Sequence>(sequence),
|
| 308 |
+
std::forward<MapFunctor>(mapFunctor),
|
| 309 |
+
std::forward<ReduceFunctor>(reduceFunctor),
|
| 310 |
+
options));
|
| 311 |
+
}
|
| 312 |
+
|
| 313 |
+
|
| 314 |
+
//! [QtConcurrent-5]
|
| 315 |
+
template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor>
|
| 316 |
+
inline ThreadEngineStarter<ResultType> startFilteredReduced(QThreadPool *pool,
|
| 317 |
+
Iterator begin,
|
| 318 |
+
Iterator end,
|
| 319 |
+
MapFunctor &&mapFunctor,
|
| 320 |
+
ReduceFunctor &&reduceFunctor,
|
| 321 |
+
ReduceOptions options)
|
| 322 |
+
{
|
| 323 |
+
using Reducer = ReduceKernel<std::decay_t<ReduceFunctor>, ResultType,
|
| 324 |
+
typename qValueType<Iterator>::value_type>;
|
| 325 |
+
using FilteredReduceType = FilteredReducedKernel<ResultType, Iterator, std::decay_t<MapFunctor>,
|
| 326 |
+
std::decay_t<ReduceFunctor>, Reducer>;
|
| 327 |
+
return startThreadEngine(
|
| 328 |
+
new FilteredReduceType(pool, begin, end, std::forward<MapFunctor>(mapFunctor),
|
| 329 |
+
std::forward<ReduceFunctor>(reduceFunctor), options));
|
| 330 |
+
}
|
| 331 |
+
|
| 332 |
+
// Repeat the two functions above, but now with an initial value!
|
| 333 |
+
//! [QtConcurrent-6]
|
| 334 |
+
template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor>
|
| 335 |
+
inline ThreadEngineStarter<ResultType> startFilteredReduced(QThreadPool *pool,
|
| 336 |
+
Sequence &&sequence,
|
| 337 |
+
MapFunctor &&mapFunctor,
|
| 338 |
+
ReduceFunctor &&reduceFunctor,
|
| 339 |
+
ResultType &&initialValue,
|
| 340 |
+
ReduceOptions options)
|
| 341 |
+
{
|
| 342 |
+
using DecayedSequence = std::decay_t<Sequence>;
|
| 343 |
+
using DecayedMapFunctor = std::decay_t<MapFunctor>;
|
| 344 |
+
using DecayedReduceFunctor = std::decay_t<ReduceFunctor>;
|
| 345 |
+
using Iterator = typename DecayedSequence::const_iterator;
|
| 346 |
+
using Reducer = ReduceKernel<DecayedReduceFunctor, ResultType,
|
| 347 |
+
typename qValueType<Iterator>::value_type>;
|
| 348 |
+
using FilteredReduceType = FilteredReducedKernel<ResultType, Iterator, DecayedMapFunctor,
|
| 349 |
+
DecayedReduceFunctor, Reducer>;
|
| 350 |
+
using SequenceHolderType = SequenceHolder2<DecayedSequence, FilteredReduceType,
|
| 351 |
+
DecayedMapFunctor, DecayedReduceFunctor>;
|
| 352 |
+
return startThreadEngine(new SequenceHolderType(
|
| 353 |
+
pool, std::forward<Sequence>(sequence), std::forward<MapFunctor>(mapFunctor),
|
| 354 |
+
std::forward<ReduceFunctor>(reduceFunctor), std::forward<ResultType>(initialValue),
|
| 355 |
+
options));
|
| 356 |
+
}
|
| 357 |
+
|
| 358 |
+
//! [QtConcurrent-7]
|
| 359 |
+
template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor>
|
| 360 |
+
inline ThreadEngineStarter<ResultType> startFilteredReduced(QThreadPool *pool,
|
| 361 |
+
Iterator begin,
|
| 362 |
+
Iterator end,
|
| 363 |
+
MapFunctor &&mapFunctor,
|
| 364 |
+
ReduceFunctor &&reduceFunctor,
|
| 365 |
+
ResultType &&initialValue,
|
| 366 |
+
ReduceOptions options)
|
| 367 |
+
{
|
| 368 |
+
using Reducer = ReduceKernel<std::decay_t<ReduceFunctor>, ResultType,
|
| 369 |
+
typename qValueType<Iterator>::value_type>;
|
| 370 |
+
using FilteredReduceType = FilteredReducedKernel<ResultType, Iterator, std::decay_t<MapFunctor>,
|
| 371 |
+
std::decay_t<ReduceFunctor>, Reducer>;
|
| 372 |
+
return startThreadEngine(
|
| 373 |
+
new FilteredReduceType(pool, begin, end, std::forward<MapFunctor>(mapFunctor),
|
| 374 |
+
std::forward<ReduceFunctor>(reduceFunctor),
|
| 375 |
+
std::forward<ResultType>(initialValue), options));
|
| 376 |
+
}
|
| 377 |
+
|
| 378 |
+
|
| 379 |
+
} // namespace QtConcurrent
|
| 380 |
+
|
| 381 |
+
|
| 382 |
+
QT_END_NAMESPACE
|
| 383 |
+
|
| 384 |
+
#endif // QT_NO_CONCURRENT
|
| 385 |
+
|
| 386 |
+
#endif
|
qt/6.8.1/msvc2022_64/include/QtConcurrent/qtconcurrentfunctionwrappers.h
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright (C) 2016 The Qt Company Ltd.
|
| 2 |
+
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
| 3 |
+
|
| 4 |
+
#ifndef QTCONCURRENT_FUNCTIONWRAPPERS_H
|
| 5 |
+
#define QTCONCURRENT_FUNCTIONWRAPPERS_H
|
| 6 |
+
|
| 7 |
+
#include <QtConcurrent/qtconcurrentcompilertest.h>
|
| 8 |
+
#include <QtConcurrent/qtconcurrentreducekernel.h>
|
| 9 |
+
#include <QtCore/qfuture.h>
|
| 10 |
+
|
| 11 |
+
#include <tuple>
|
| 12 |
+
|
| 13 |
+
#if !defined(QT_NO_CONCURRENT) || defined(Q_QDOC)
|
| 14 |
+
|
| 15 |
+
QT_BEGIN_NAMESPACE
|
| 16 |
+
|
| 17 |
+
namespace QtPrivate {
|
| 18 |
+
|
| 19 |
+
struct PushBackWrapper
|
| 20 |
+
{
|
| 21 |
+
template <class C, class U>
|
| 22 |
+
inline void operator()(C &c, const U &u) const
|
| 23 |
+
{
|
| 24 |
+
return c.push_back(u);
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
template <class C, class U>
|
| 28 |
+
inline void operator()(C &c, U &&u) const
|
| 29 |
+
{
|
| 30 |
+
return c.push_back(u);
|
| 31 |
+
}
|
| 32 |
+
};
|
| 33 |
+
|
| 34 |
+
// -- MapResultType
|
| 35 |
+
|
| 36 |
+
template <class T, class Enable = void>
|
| 37 |
+
struct Argument
|
| 38 |
+
{
|
| 39 |
+
using Type = void;
|
| 40 |
+
};
|
| 41 |
+
|
| 42 |
+
template <class Sequence>
|
| 43 |
+
struct Argument<Sequence, typename std::enable_if<IsIterableValue<Sequence>>::type>
|
| 44 |
+
{
|
| 45 |
+
using Type = std::decay_t<decltype(*std::declval<Sequence>().begin())>;
|
| 46 |
+
};
|
| 47 |
+
|
| 48 |
+
template <class Iterator>
|
| 49 |
+
struct Argument<Iterator, typename std::enable_if<IsDereferenceableValue<Iterator>>::type>
|
| 50 |
+
{
|
| 51 |
+
using Type = std::decay_t<decltype(*std::declval<Iterator>())>;
|
| 52 |
+
};
|
| 53 |
+
|
| 54 |
+
template <class T>
|
| 55 |
+
using ArgumentType = typename Argument<T>::Type;
|
| 56 |
+
|
| 57 |
+
template <class T, class MapFunctor>
|
| 58 |
+
struct MapResult
|
| 59 |
+
{
|
| 60 |
+
static_assert(std::is_invocable_v<std::decay_t<MapFunctor>, ArgumentType<T>>,
|
| 61 |
+
"It's not possible to invoke the function with passed argument.");
|
| 62 |
+
using Type = std::invoke_result_t<std::decay_t<MapFunctor>, ArgumentType<T>>;
|
| 63 |
+
};
|
| 64 |
+
|
| 65 |
+
template <class T, class MapFunctor>
|
| 66 |
+
using MapResultType = typename MapResult<T, MapFunctor>::Type;
|
| 67 |
+
|
| 68 |
+
// -- ReduceResultType
|
| 69 |
+
|
| 70 |
+
template <class T>
|
| 71 |
+
struct ReduceResultType;
|
| 72 |
+
|
| 73 |
+
template <class U, class V>
|
| 74 |
+
struct ReduceResultType<void(*)(U&,V)>
|
| 75 |
+
{
|
| 76 |
+
using ResultType = U;
|
| 77 |
+
};
|
| 78 |
+
|
| 79 |
+
template <class T, class C, class U>
|
| 80 |
+
struct ReduceResultType<T(C::*)(U)>
|
| 81 |
+
{
|
| 82 |
+
using ResultType = C;
|
| 83 |
+
};
|
| 84 |
+
|
| 85 |
+
template <class U, class V>
|
| 86 |
+
struct ReduceResultType<std::function<void(U&, V)>>
|
| 87 |
+
{
|
| 88 |
+
using ResultType = U;
|
| 89 |
+
};
|
| 90 |
+
|
| 91 |
+
template <typename R, typename ...A>
|
| 92 |
+
struct ReduceResultType<R(*)(A...)>
|
| 93 |
+
{
|
| 94 |
+
using ResultType = typename std::tuple_element<0, std::tuple<A...>>::type;
|
| 95 |
+
};
|
| 96 |
+
|
| 97 |
+
template <class U, class V>
|
| 98 |
+
struct ReduceResultType<void(*)(U&,V) noexcept>
|
| 99 |
+
{
|
| 100 |
+
using ResultType = U;
|
| 101 |
+
};
|
| 102 |
+
|
| 103 |
+
template <class T, class C, class U>
|
| 104 |
+
struct ReduceResultType<T(C::*)(U) noexcept>
|
| 105 |
+
{
|
| 106 |
+
using ResultType = C;
|
| 107 |
+
};
|
| 108 |
+
|
| 109 |
+
template<class T, class Enable = void>
|
| 110 |
+
inline constexpr bool hasCallOperator_v = false;
|
| 111 |
+
|
| 112 |
+
template<class T>
|
| 113 |
+
inline constexpr bool hasCallOperator_v<T, std::void_t<decltype(&T::operator())>> = true;
|
| 114 |
+
|
| 115 |
+
template<class T, class Enable = void>
|
| 116 |
+
inline constexpr bool isIterator_v = false;
|
| 117 |
+
|
| 118 |
+
template<class T>
|
| 119 |
+
inline constexpr bool isIterator_v<T, std::void_t<typename std::iterator_traits<T>::value_type>> =
|
| 120 |
+
true;
|
| 121 |
+
|
| 122 |
+
template <class Callable, class Sequence>
|
| 123 |
+
using isInvocable = std::is_invocable<Callable, typename std::decay_t<Sequence>::value_type>;
|
| 124 |
+
|
| 125 |
+
template <class InitialValueType, class ResultType>
|
| 126 |
+
inline constexpr bool isInitialValueCompatible_v = std::conjunction_v<
|
| 127 |
+
std::is_convertible<InitialValueType, ResultType>,
|
| 128 |
+
std::negation<std::is_same<std::decay_t<InitialValueType>, QtConcurrent::ReduceOption>>>;
|
| 129 |
+
|
| 130 |
+
template<class Callable, class Enable = void>
|
| 131 |
+
struct ReduceResultTypeHelper
|
| 132 |
+
{
|
| 133 |
+
};
|
| 134 |
+
|
| 135 |
+
template <class Callable>
|
| 136 |
+
struct ReduceResultTypeHelper<Callable,
|
| 137 |
+
typename std::enable_if_t<std::is_function_v<std::remove_pointer_t<std::decay_t<Callable>>>
|
| 138 |
+
|| std::is_member_function_pointer_v<std::decay_t<Callable>>>>
|
| 139 |
+
{
|
| 140 |
+
using type = typename QtPrivate::ReduceResultType<std::decay_t<Callable>>::ResultType;
|
| 141 |
+
};
|
| 142 |
+
|
| 143 |
+
template <class Callable>
|
| 144 |
+
struct ReduceResultTypeHelper<Callable,
|
| 145 |
+
typename std::enable_if_t<!std::is_function_v<std::remove_pointer_t<std::decay_t<Callable>>>
|
| 146 |
+
&& hasCallOperator_v<std::decay_t<Callable>>>>
|
| 147 |
+
{
|
| 148 |
+
using type = std::decay_t<typename QtPrivate::ArgResolver<Callable>::First>;
|
| 149 |
+
};
|
| 150 |
+
|
| 151 |
+
// -- MapSequenceResultType
|
| 152 |
+
|
| 153 |
+
template <class InputSequence, class MapFunctor>
|
| 154 |
+
struct MapSequenceResultType
|
| 155 |
+
{
|
| 156 |
+
static_assert(std::is_same_v<typename InputSequence::value_type,
|
| 157 |
+
QtPrivate::MapResultType<InputSequence, MapFunctor>>,
|
| 158 |
+
"Couldn't deduce the output sequence type, you must specify it explicitly.");
|
| 159 |
+
typedef InputSequence ResultType;
|
| 160 |
+
};
|
| 161 |
+
|
| 162 |
+
#ifndef QT_NO_TEMPLATE_TEMPLATE_PARAMETERS
|
| 163 |
+
|
| 164 |
+
template <template <typename...> class InputSequence, typename MapFunctor, typename ...T>
|
| 165 |
+
struct MapSequenceResultType<InputSequence<T...>, MapFunctor>
|
| 166 |
+
{
|
| 167 |
+
typedef InputSequence<QtPrivate::MapResultType<InputSequence<T...>, MapFunctor>> ResultType;
|
| 168 |
+
};
|
| 169 |
+
|
| 170 |
+
#endif // QT_NO_TEMPLATE_TEMPLATE_PARAMETER
|
| 171 |
+
|
| 172 |
+
} // namespace QtPrivate.
|
| 173 |
+
|
| 174 |
+
|
| 175 |
+
QT_END_NAMESPACE
|
| 176 |
+
|
| 177 |
+
#endif // QT_NO_CONCURRENT
|
| 178 |
+
|
| 179 |
+
#endif
|
qt/6.8.1/msvc2022_64/include/QtConcurrent/qtconcurrentiteratekernel.h
ADDED
|
@@ -0,0 +1,335 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright (C) 2016 The Qt Company Ltd.
|
| 2 |
+
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
| 3 |
+
|
| 4 |
+
#ifndef QTCONCURRENT_ITERATEKERNEL_H
|
| 5 |
+
#define QTCONCURRENT_ITERATEKERNEL_H
|
| 6 |
+
|
| 7 |
+
#include <QtConcurrent/qtconcurrent_global.h>
|
| 8 |
+
|
| 9 |
+
#if !defined(QT_NO_CONCURRENT) || defined(Q_QDOC)
|
| 10 |
+
|
| 11 |
+
#include <QtCore/qatomic.h>
|
| 12 |
+
#include <QtConcurrent/qtconcurrentmedian.h>
|
| 13 |
+
#include <QtConcurrent/qtconcurrentthreadengine.h>
|
| 14 |
+
|
| 15 |
+
#include <iterator>
|
| 16 |
+
|
| 17 |
+
QT_BEGIN_NAMESPACE
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
namespace QtConcurrent {
|
| 22 |
+
|
| 23 |
+
/*
|
| 24 |
+
The BlockSizeManager class manages how many iterations a thread should
|
| 25 |
+
reserve and process at a time. This is done by measuring the time spent
|
| 26 |
+
in the user code versus the control part code, and then increasing
|
| 27 |
+
the block size if the ratio between them is to small. The block size
|
| 28 |
+
management is done on the basis of the median of several timing measurements,
|
| 29 |
+
and it is done individually for each thread.
|
| 30 |
+
*/
|
| 31 |
+
class Q_CONCURRENT_EXPORT BlockSizeManager
|
| 32 |
+
{
|
| 33 |
+
public:
|
| 34 |
+
explicit BlockSizeManager(QThreadPool *pool, int iterationCount);
|
| 35 |
+
|
| 36 |
+
void timeBeforeUser();
|
| 37 |
+
void timeAfterUser();
|
| 38 |
+
int blockSize();
|
| 39 |
+
|
| 40 |
+
private:
|
| 41 |
+
inline bool blockSizeMaxed()
|
| 42 |
+
{
|
| 43 |
+
return (m_blockSize >= maxBlockSize);
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
const int maxBlockSize;
|
| 47 |
+
qint64 beforeUser;
|
| 48 |
+
qint64 afterUser;
|
| 49 |
+
Median controlPartElapsed;
|
| 50 |
+
Median userPartElapsed;
|
| 51 |
+
int m_blockSize;
|
| 52 |
+
|
| 53 |
+
Q_DISABLE_COPY(BlockSizeManager)
|
| 54 |
+
};
|
| 55 |
+
|
| 56 |
+
template <typename T>
|
| 57 |
+
class ResultReporter
|
| 58 |
+
{
|
| 59 |
+
public:
|
| 60 |
+
ResultReporter(ThreadEngine<T> *_threadEngine, T &_defaultValue)
|
| 61 |
+
: threadEngine(_threadEngine), defaultValue(_defaultValue)
|
| 62 |
+
{
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
void reserveSpace(int resultCount)
|
| 66 |
+
{
|
| 67 |
+
currentResultCount = resultCount;
|
| 68 |
+
resizeList(qMax(resultCount, vector.size()));
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
void reportResults(int begin)
|
| 72 |
+
{
|
| 73 |
+
const int useVectorThreshold = 4; // Tunable parameter.
|
| 74 |
+
if (currentResultCount > useVectorThreshold) {
|
| 75 |
+
resizeList(currentResultCount);
|
| 76 |
+
threadEngine->reportResults(vector, begin);
|
| 77 |
+
} else {
|
| 78 |
+
for (int i = 0; i < currentResultCount; ++i)
|
| 79 |
+
threadEngine->reportResult(&vector.at(i), begin + i);
|
| 80 |
+
}
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
inline T * getPointer()
|
| 84 |
+
{
|
| 85 |
+
return vector.data();
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
int currentResultCount = 0;
|
| 89 |
+
ThreadEngine<T> *threadEngine;
|
| 90 |
+
QList<T> vector;
|
| 91 |
+
|
| 92 |
+
private:
|
| 93 |
+
void resizeList(qsizetype size)
|
| 94 |
+
{
|
| 95 |
+
if constexpr (std::is_default_constructible_v<T>)
|
| 96 |
+
vector.resize(size);
|
| 97 |
+
else
|
| 98 |
+
vector.resize(size, defaultValue);
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
T &defaultValue;
|
| 102 |
+
};
|
| 103 |
+
|
| 104 |
+
template <>
|
| 105 |
+
class ResultReporter<void>
|
| 106 |
+
{
|
| 107 |
+
public:
|
| 108 |
+
inline ResultReporter(ThreadEngine<void> *) { }
|
| 109 |
+
inline void reserveSpace(int) { }
|
| 110 |
+
inline void reportResults(int) { }
|
| 111 |
+
inline void * getPointer() { return nullptr; }
|
| 112 |
+
};
|
| 113 |
+
|
| 114 |
+
template<typename T>
|
| 115 |
+
struct DefaultValueContainer
|
| 116 |
+
{
|
| 117 |
+
template<typename U = T>
|
| 118 |
+
DefaultValueContainer(U &&_value) : value(std::forward<U>(_value))
|
| 119 |
+
{
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
T value;
|
| 123 |
+
};
|
| 124 |
+
|
| 125 |
+
template<>
|
| 126 |
+
struct DefaultValueContainer<void>
|
| 127 |
+
{
|
| 128 |
+
};
|
| 129 |
+
|
| 130 |
+
inline bool selectIteration(std::bidirectional_iterator_tag)
|
| 131 |
+
{
|
| 132 |
+
return false; // while
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
inline bool selectIteration(std::forward_iterator_tag)
|
| 136 |
+
{
|
| 137 |
+
return false; // while
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
inline bool selectIteration(std::random_access_iterator_tag)
|
| 141 |
+
{
|
| 142 |
+
return true; // for
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
template <typename Iterator, typename T>
|
| 146 |
+
class IterateKernel : public ThreadEngine<T>
|
| 147 |
+
{
|
| 148 |
+
using IteratorCategory = typename std::iterator_traits<Iterator>::iterator_category;
|
| 149 |
+
|
| 150 |
+
public:
|
| 151 |
+
typedef T ResultType;
|
| 152 |
+
|
| 153 |
+
template<typename U = T, std::enable_if_t<std::is_same_v<U, void>, bool> = true>
|
| 154 |
+
IterateKernel(QThreadPool *pool, Iterator _begin, Iterator _end)
|
| 155 |
+
: ThreadEngine<U>(pool),
|
| 156 |
+
begin(_begin),
|
| 157 |
+
end(_end),
|
| 158 |
+
current(_begin),
|
| 159 |
+
iterationCount(selectIteration(IteratorCategory()) ? static_cast<int>(std::distance(_begin, _end)) : 0),
|
| 160 |
+
forIteration(selectIteration(IteratorCategory())),
|
| 161 |
+
progressReportingEnabled(true)
|
| 162 |
+
{
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
template<typename U = T, std::enable_if_t<!std::is_same_v<U, void>, bool> = true>
|
| 166 |
+
IterateKernel(QThreadPool *pool, Iterator _begin, Iterator _end)
|
| 167 |
+
: ThreadEngine<U>(pool),
|
| 168 |
+
begin(_begin),
|
| 169 |
+
end(_end),
|
| 170 |
+
current(_begin),
|
| 171 |
+
iterationCount(selectIteration(IteratorCategory()) ? static_cast<int>(std::distance(_begin, _end)) : 0),
|
| 172 |
+
forIteration(selectIteration(IteratorCategory())),
|
| 173 |
+
progressReportingEnabled(true),
|
| 174 |
+
defaultValue(U())
|
| 175 |
+
{
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
template<typename U = T, std::enable_if_t<!std::is_same_v<U, void>, bool> = true>
|
| 179 |
+
IterateKernel(QThreadPool *pool, Iterator _begin, Iterator _end, U &&_defaultValue)
|
| 180 |
+
: ThreadEngine<U>(pool),
|
| 181 |
+
begin(_begin),
|
| 182 |
+
end(_end),
|
| 183 |
+
current(_begin),
|
| 184 |
+
iterationCount(selectIteration(IteratorCategory()) ? static_cast<int>(std::distance(_begin, _end)) : 0),
|
| 185 |
+
forIteration(selectIteration(IteratorCategory())),
|
| 186 |
+
progressReportingEnabled(true),
|
| 187 |
+
defaultValue(std::forward<U>(_defaultValue))
|
| 188 |
+
{
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
+
virtual ~IterateKernel() { }
|
| 192 |
+
|
| 193 |
+
virtual bool runIteration(Iterator, int , T *) { return false; }
|
| 194 |
+
virtual bool runIterations(Iterator, int, int, T *) { return false; }
|
| 195 |
+
|
| 196 |
+
void start() override
|
| 197 |
+
{
|
| 198 |
+
progressReportingEnabled = this->isProgressReportingEnabled();
|
| 199 |
+
if (progressReportingEnabled && iterationCount > 0)
|
| 200 |
+
this->setProgressRange(0, iterationCount);
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
bool shouldStartThread() override
|
| 204 |
+
{
|
| 205 |
+
if (forIteration)
|
| 206 |
+
return (currentIndex.loadRelaxed() < iterationCount) && !this->shouldThrottleThread();
|
| 207 |
+
else // whileIteration
|
| 208 |
+
return (iteratorThreads.loadRelaxed() == 0);
|
| 209 |
+
}
|
| 210 |
+
|
| 211 |
+
ThreadFunctionResult threadFunction() override
|
| 212 |
+
{
|
| 213 |
+
if (forIteration)
|
| 214 |
+
return this->forThreadFunction();
|
| 215 |
+
else // whileIteration
|
| 216 |
+
return this->whileThreadFunction();
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
ThreadFunctionResult forThreadFunction()
|
| 220 |
+
{
|
| 221 |
+
BlockSizeManager blockSizeManager(ThreadEngineBase::threadPool, iterationCount);
|
| 222 |
+
ResultReporter<T> resultReporter = createResultsReporter();
|
| 223 |
+
|
| 224 |
+
for(;;) {
|
| 225 |
+
if (this->isCanceled())
|
| 226 |
+
break;
|
| 227 |
+
|
| 228 |
+
const int currentBlockSize = blockSizeManager.blockSize();
|
| 229 |
+
|
| 230 |
+
if (currentIndex.loadRelaxed() >= iterationCount)
|
| 231 |
+
break;
|
| 232 |
+
|
| 233 |
+
// Atomically reserve a block of iterationCount for this thread.
|
| 234 |
+
const int beginIndex = currentIndex.fetchAndAddRelease(currentBlockSize);
|
| 235 |
+
const int endIndex = qMin(beginIndex + currentBlockSize, iterationCount);
|
| 236 |
+
|
| 237 |
+
if (beginIndex >= endIndex) {
|
| 238 |
+
// No more work
|
| 239 |
+
break;
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
+
this->waitForResume(); // (only waits if the qfuture is paused.)
|
| 243 |
+
|
| 244 |
+
if (shouldStartThread())
|
| 245 |
+
this->startThread();
|
| 246 |
+
|
| 247 |
+
const int finalBlockSize = endIndex - beginIndex; // block size adjusted for possible end-of-range
|
| 248 |
+
resultReporter.reserveSpace(finalBlockSize);
|
| 249 |
+
|
| 250 |
+
// Call user code with the current iteration range.
|
| 251 |
+
blockSizeManager.timeBeforeUser();
|
| 252 |
+
const bool resultsAvailable = this->runIterations(begin, beginIndex, endIndex, resultReporter.getPointer());
|
| 253 |
+
blockSizeManager.timeAfterUser();
|
| 254 |
+
|
| 255 |
+
if (resultsAvailable)
|
| 256 |
+
resultReporter.reportResults(beginIndex);
|
| 257 |
+
|
| 258 |
+
// Report progress if progress reporting enabled.
|
| 259 |
+
if (progressReportingEnabled) {
|
| 260 |
+
completed.fetchAndAddAcquire(finalBlockSize);
|
| 261 |
+
this->setProgressValue(this->completed.loadRelaxed());
|
| 262 |
+
}
|
| 263 |
+
|
| 264 |
+
if (this->shouldThrottleThread())
|
| 265 |
+
return ThrottleThread;
|
| 266 |
+
}
|
| 267 |
+
return ThreadFinished;
|
| 268 |
+
}
|
| 269 |
+
|
| 270 |
+
ThreadFunctionResult whileThreadFunction()
|
| 271 |
+
{
|
| 272 |
+
if (iteratorThreads.testAndSetAcquire(0, 1) == false)
|
| 273 |
+
return ThreadFinished;
|
| 274 |
+
|
| 275 |
+
ResultReporter<T> resultReporter = createResultsReporter();
|
| 276 |
+
resultReporter.reserveSpace(1);
|
| 277 |
+
|
| 278 |
+
while (current != end) {
|
| 279 |
+
// The following two lines breaks support for input iterators according to
|
| 280 |
+
// the sgi docs: dereferencing prev after calling ++current is not allowed
|
| 281 |
+
// on input iterators. (prev is dereferenced inside user.runIteration())
|
| 282 |
+
Iterator prev = current;
|
| 283 |
+
++current;
|
| 284 |
+
int index = currentIndex.fetchAndAddRelaxed(1);
|
| 285 |
+
iteratorThreads.testAndSetRelease(1, 0);
|
| 286 |
+
|
| 287 |
+
this->waitForResume(); // (only waits if the qfuture is paused.)
|
| 288 |
+
|
| 289 |
+
if (shouldStartThread())
|
| 290 |
+
this->startThread();
|
| 291 |
+
|
| 292 |
+
const bool resultAavailable = this->runIteration(prev, index, resultReporter.getPointer());
|
| 293 |
+
if (resultAavailable)
|
| 294 |
+
resultReporter.reportResults(index);
|
| 295 |
+
|
| 296 |
+
if (this->shouldThrottleThread())
|
| 297 |
+
return ThrottleThread;
|
| 298 |
+
|
| 299 |
+
if (iteratorThreads.testAndSetAcquire(0, 1) == false)
|
| 300 |
+
return ThreadFinished;
|
| 301 |
+
}
|
| 302 |
+
|
| 303 |
+
return ThreadFinished;
|
| 304 |
+
}
|
| 305 |
+
|
| 306 |
+
private:
|
| 307 |
+
ResultReporter<T> createResultsReporter()
|
| 308 |
+
{
|
| 309 |
+
if constexpr (!std::is_same_v<T, void>)
|
| 310 |
+
return ResultReporter<T>(this, defaultValue.value);
|
| 311 |
+
else
|
| 312 |
+
return ResultReporter<T>(this);
|
| 313 |
+
}
|
| 314 |
+
|
| 315 |
+
public:
|
| 316 |
+
const Iterator begin;
|
| 317 |
+
const Iterator end;
|
| 318 |
+
Iterator current;
|
| 319 |
+
QAtomicInt currentIndex;
|
| 320 |
+
QAtomicInt iteratorThreads;
|
| 321 |
+
QAtomicInt completed;
|
| 322 |
+
const int iterationCount;
|
| 323 |
+
const bool forIteration;
|
| 324 |
+
bool progressReportingEnabled;
|
| 325 |
+
DefaultValueContainer<ResultType> defaultValue;
|
| 326 |
+
};
|
| 327 |
+
|
| 328 |
+
} // namespace QtConcurrent
|
| 329 |
+
|
| 330 |
+
|
| 331 |
+
QT_END_NAMESPACE
|
| 332 |
+
|
| 333 |
+
#endif // QT_NO_CONCURRENT
|
| 334 |
+
|
| 335 |
+
#endif
|
qt/6.8.1/msvc2022_64/include/QtConcurrent/qtconcurrentmap.h
ADDED
|
@@ -0,0 +1,823 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright (C) 2016 The Qt Company Ltd.
|
| 2 |
+
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
| 3 |
+
|
| 4 |
+
#ifndef QTCONCURRENT_MAP_H
|
| 5 |
+
#define QTCONCURRENT_MAP_H
|
| 6 |
+
|
| 7 |
+
#if 0
|
| 8 |
+
#pragma qt_class(QtConcurrentMap)
|
| 9 |
+
#endif
|
| 10 |
+
|
| 11 |
+
#include <QtConcurrent/qtconcurrent_global.h>
|
| 12 |
+
|
| 13 |
+
#if !defined(QT_NO_CONCURRENT) || defined(Q_QDOC)
|
| 14 |
+
|
| 15 |
+
#include <QtConcurrent/qtconcurrentmapkernel.h>
|
| 16 |
+
#include <QtConcurrent/qtconcurrentreducekernel.h>
|
| 17 |
+
#include <QtConcurrent/qtconcurrentfunctionwrappers.h>
|
| 18 |
+
|
| 19 |
+
QT_BEGIN_NAMESPACE
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
namespace QtConcurrent {
|
| 24 |
+
|
| 25 |
+
// map() on sequences
|
| 26 |
+
template <typename Sequence, typename MapFunctor>
|
| 27 |
+
QFuture<void> map(QThreadPool *pool, Sequence &&sequence, MapFunctor &&map)
|
| 28 |
+
{
|
| 29 |
+
return startMap(pool, sequence.begin(), sequence.end(), std::forward<MapFunctor>(map));
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
template <typename Sequence, typename MapFunctor>
|
| 33 |
+
QFuture<void> map(Sequence &&sequence, MapFunctor &&map)
|
| 34 |
+
{
|
| 35 |
+
return startMap(QThreadPool::globalInstance(), sequence.begin(), sequence.end(),
|
| 36 |
+
std::forward<MapFunctor>(map));
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
// map() on iterators
|
| 40 |
+
template <typename Iterator, typename MapFunctor>
|
| 41 |
+
QFuture<void> map(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor &&map)
|
| 42 |
+
{
|
| 43 |
+
return startMap(pool, begin, end, std::forward<MapFunctor>(map));
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
template <typename Iterator, typename MapFunctor>
|
| 47 |
+
QFuture<void> map(Iterator begin, Iterator end, MapFunctor &&map)
|
| 48 |
+
{
|
| 49 |
+
return startMap(QThreadPool::globalInstance(), begin, end, std::forward<MapFunctor>(map));
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
// mappedReduced() for sequences.
|
| 53 |
+
template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor>
|
| 54 |
+
QFuture<ResultType> mappedReduced(QThreadPool *pool,
|
| 55 |
+
Sequence &&sequence,
|
| 56 |
+
MapFunctor &&map,
|
| 57 |
+
ReduceFunctor &&reduce,
|
| 58 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 59 |
+
| SequentialReduce))
|
| 60 |
+
{
|
| 61 |
+
return startMappedReduced<QtPrivate::MapResultType<Sequence, MapFunctor>, ResultType>
|
| 62 |
+
(pool, std::forward<Sequence>(sequence), std::forward<MapFunctor>(map),
|
| 63 |
+
std::forward<ReduceFunctor>(reduce), options);
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor>
|
| 67 |
+
QFuture<ResultType> mappedReduced(Sequence &&sequence,
|
| 68 |
+
MapFunctor &&map,
|
| 69 |
+
ReduceFunctor &&reduce,
|
| 70 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 71 |
+
| SequentialReduce))
|
| 72 |
+
{
|
| 73 |
+
return startMappedReduced<QtPrivate::MapResultType<Sequence, MapFunctor>, ResultType>
|
| 74 |
+
(QThreadPool::globalInstance(), std::forward<Sequence>(sequence),
|
| 75 |
+
std::forward<MapFunctor>(map), std::forward<ReduceFunctor>(reduce), options);
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
#ifdef Q_QDOC
|
| 79 |
+
template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor,
|
| 80 |
+
typename InitialValueType>
|
| 81 |
+
#else
|
| 82 |
+
template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor,
|
| 83 |
+
typename InitialValueType,
|
| 84 |
+
std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
|
| 85 |
+
int> = 0>
|
| 86 |
+
#endif
|
| 87 |
+
QFuture<ResultType> mappedReduced(QThreadPool *pool,
|
| 88 |
+
Sequence &&sequence,
|
| 89 |
+
MapFunctor &&map,
|
| 90 |
+
ReduceFunctor &&reduce,
|
| 91 |
+
InitialValueType &&initialValue,
|
| 92 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 93 |
+
| SequentialReduce))
|
| 94 |
+
{
|
| 95 |
+
return startMappedReduced<QtPrivate::MapResultType<Sequence, MapFunctor>, ResultType>(
|
| 96 |
+
pool, std::forward<Sequence>(sequence), std::forward<MapFunctor>(map),
|
| 97 |
+
std::forward<ReduceFunctor>(reduce),
|
| 98 |
+
ResultType(std::forward<InitialValueType>(initialValue)), options);
|
| 99 |
+
}
|
| 100 |
+
#ifdef Q_QDOC
|
| 101 |
+
template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor,
|
| 102 |
+
typename InitialValueType>
|
| 103 |
+
#else
|
| 104 |
+
template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor,
|
| 105 |
+
typename InitialValueType,
|
| 106 |
+
std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
|
| 107 |
+
int> = 0>
|
| 108 |
+
#endif
|
| 109 |
+
QFuture<ResultType> mappedReduced(Sequence &&sequence,
|
| 110 |
+
MapFunctor &&map,
|
| 111 |
+
ReduceFunctor &&reduce,
|
| 112 |
+
InitialValueType &&initialValue,
|
| 113 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 114 |
+
| SequentialReduce))
|
| 115 |
+
{
|
| 116 |
+
return startMappedReduced<QtPrivate::MapResultType<Sequence, MapFunctor>, ResultType>
|
| 117 |
+
(QThreadPool::globalInstance(), std::forward<Sequence>(sequence),
|
| 118 |
+
std::forward<MapFunctor>(map), std::forward<ReduceFunctor>(reduce),
|
| 119 |
+
ResultType(std::forward<InitialValueType>(initialValue)), options);
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
template <typename Sequence, typename MapFunctor, typename ReduceFunctor,
|
| 123 |
+
std::enable_if_t<QtPrivate::isInvocable<MapFunctor, Sequence>::value, int> = 0,
|
| 124 |
+
typename ResultType = typename QtPrivate::ReduceResultTypeHelper<ReduceFunctor>::type>
|
| 125 |
+
QFuture<ResultType> mappedReduced(QThreadPool *pool,
|
| 126 |
+
Sequence &&sequence,
|
| 127 |
+
MapFunctor &&map,
|
| 128 |
+
ReduceFunctor &&reduce,
|
| 129 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 130 |
+
| SequentialReduce))
|
| 131 |
+
{
|
| 132 |
+
return startMappedReduced<QtPrivate::MapResultType<Sequence, MapFunctor>, ResultType>
|
| 133 |
+
(pool, std::forward<Sequence>(sequence), std::forward<MapFunctor>(map),
|
| 134 |
+
std::forward<ReduceFunctor>(reduce), options);
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
template <typename Sequence, typename MapFunctor, typename ReduceFunctor,
|
| 138 |
+
std::enable_if_t<QtPrivate::isInvocable<MapFunctor, Sequence>::value, int> = 0,
|
| 139 |
+
typename ResultType = typename QtPrivate::ReduceResultTypeHelper<ReduceFunctor>::type>
|
| 140 |
+
QFuture<ResultType> mappedReduced(Sequence &&sequence,
|
| 141 |
+
MapFunctor &&map,
|
| 142 |
+
ReduceFunctor &&reduce,
|
| 143 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 144 |
+
| SequentialReduce))
|
| 145 |
+
{
|
| 146 |
+
return startMappedReduced<QtPrivate::MapResultType<Sequence, MapFunctor>, ResultType>
|
| 147 |
+
(QThreadPool::globalInstance(), std::forward<Sequence>(sequence),
|
| 148 |
+
std::forward<MapFunctor>(map), std::forward<ReduceFunctor>(reduce), options);
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
#ifdef Q_QDOC
|
| 152 |
+
template <typename Sequence, typename MapFunctor, typename ReduceFunctor, typename ResultType,
|
| 153 |
+
typename InitialValueType>
|
| 154 |
+
#else
|
| 155 |
+
template <typename Sequence, typename MapFunctor, typename ReduceFunctor, typename InitialValueType,
|
| 156 |
+
std::enable_if_t<QtPrivate::isInvocable<MapFunctor, Sequence>::value, int> = 0,
|
| 157 |
+
typename ResultType = typename QtPrivate::ReduceResultTypeHelper<ReduceFunctor>::type,
|
| 158 |
+
std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
|
| 159 |
+
int> = 0>
|
| 160 |
+
#endif
|
| 161 |
+
QFuture<ResultType> mappedReduced(QThreadPool *pool,
|
| 162 |
+
Sequence &&sequence,
|
| 163 |
+
MapFunctor &&map,
|
| 164 |
+
ReduceFunctor &&reduce,
|
| 165 |
+
InitialValueType &&initialValue,
|
| 166 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 167 |
+
| SequentialReduce))
|
| 168 |
+
{
|
| 169 |
+
return startMappedReduced<QtPrivate::MapResultType<Sequence, MapFunctor>, ResultType>(
|
| 170 |
+
pool, std::forward<Sequence>(sequence), std::forward<MapFunctor>(map),
|
| 171 |
+
std::forward<ReduceFunctor>(reduce),
|
| 172 |
+
ResultType(std::forward<InitialValueType>(initialValue)), options);
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
#ifdef Q_QDOC
|
| 176 |
+
template <typename Sequence, typename MapFunctor, typename ReduceFunctor, typename ResultType,
|
| 177 |
+
typename InitialValueType>
|
| 178 |
+
#else
|
| 179 |
+
template <typename Sequence, typename MapFunctor, typename ReduceFunctor, typename InitialValueType,
|
| 180 |
+
std::enable_if_t<QtPrivate::isInvocable<MapFunctor, Sequence>::value, int> = 0,
|
| 181 |
+
typename ResultType = typename QtPrivate::ReduceResultTypeHelper<ReduceFunctor>::type,
|
| 182 |
+
std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
|
| 183 |
+
int> = 0>
|
| 184 |
+
#endif
|
| 185 |
+
QFuture<ResultType> mappedReduced(Sequence &&sequence,
|
| 186 |
+
MapFunctor &&map,
|
| 187 |
+
ReduceFunctor &&reduce,
|
| 188 |
+
InitialValueType &&initialValue,
|
| 189 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 190 |
+
| SequentialReduce))
|
| 191 |
+
{
|
| 192 |
+
return startMappedReduced<QtPrivate::MapResultType<Sequence, MapFunctor>, ResultType>
|
| 193 |
+
(QThreadPool::globalInstance(), std::forward<Sequence>(sequence),
|
| 194 |
+
std::forward<MapFunctor>(map), std::forward<ReduceFunctor>(reduce),
|
| 195 |
+
ResultType(std::forward<InitialValueType>(initialValue)), options);
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
// mappedReduced() for iterators
|
| 199 |
+
template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor>
|
| 200 |
+
QFuture<ResultType> mappedReduced(QThreadPool *pool,
|
| 201 |
+
Iterator begin,
|
| 202 |
+
Iterator end,
|
| 203 |
+
MapFunctor &&map,
|
| 204 |
+
ReduceFunctor &&reduce,
|
| 205 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 206 |
+
| SequentialReduce))
|
| 207 |
+
{
|
| 208 |
+
return startMappedReduced<QtPrivate::MapResultType<Iterator, MapFunctor>, ResultType>
|
| 209 |
+
(pool, begin, end, std::forward<MapFunctor>(map), std::forward<ReduceFunctor>(reduce),
|
| 210 |
+
options);
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor>
|
| 214 |
+
QFuture<ResultType> mappedReduced(Iterator begin,
|
| 215 |
+
Iterator end,
|
| 216 |
+
MapFunctor &&map,
|
| 217 |
+
ReduceFunctor &&reduce,
|
| 218 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 219 |
+
| SequentialReduce))
|
| 220 |
+
{
|
| 221 |
+
return startMappedReduced<QtPrivate::MapResultType<Iterator, MapFunctor>, ResultType>
|
| 222 |
+
(QThreadPool::globalInstance(), begin, end, std::forward<MapFunctor>(map),
|
| 223 |
+
std::forward<ReduceFunctor>(reduce), options);
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
#ifdef Q_QDOC
|
| 227 |
+
template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor,
|
| 228 |
+
typename InitialValueType>
|
| 229 |
+
#else
|
| 230 |
+
template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor,
|
| 231 |
+
typename InitialValueType,
|
| 232 |
+
std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
|
| 233 |
+
int> = 0>
|
| 234 |
+
#endif
|
| 235 |
+
QFuture<ResultType> mappedReduced(QThreadPool *pool,
|
| 236 |
+
Iterator begin,
|
| 237 |
+
Iterator end,
|
| 238 |
+
MapFunctor &&map,
|
| 239 |
+
ReduceFunctor &&reduce,
|
| 240 |
+
InitialValueType &&initialValue,
|
| 241 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 242 |
+
| SequentialReduce))
|
| 243 |
+
{
|
| 244 |
+
return startMappedReduced<QtPrivate::MapResultType<Iterator, MapFunctor>, ResultType>
|
| 245 |
+
(pool, begin, end, std::forward<MapFunctor>(map), std::forward<ReduceFunctor>(reduce),
|
| 246 |
+
ResultType(std::forward<InitialValueType>(initialValue)), options);
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
#ifdef Q_QDOC
|
| 250 |
+
template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor,
|
| 251 |
+
typename InitialValueType>
|
| 252 |
+
#else
|
| 253 |
+
template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor,
|
| 254 |
+
typename InitialValueType,
|
| 255 |
+
std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
|
| 256 |
+
int> = 0>
|
| 257 |
+
#endif
|
| 258 |
+
QFuture<ResultType> mappedReduced(Iterator begin,
|
| 259 |
+
Iterator end,
|
| 260 |
+
MapFunctor &&map,
|
| 261 |
+
ReduceFunctor &&reduce,
|
| 262 |
+
InitialValueType &&initialValue,
|
| 263 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 264 |
+
| SequentialReduce))
|
| 265 |
+
{
|
| 266 |
+
return startMappedReduced<QtPrivate::MapResultType<Iterator, MapFunctor>, ResultType>
|
| 267 |
+
(QThreadPool::globalInstance(), begin, end, std::forward<MapFunctor>(map),
|
| 268 |
+
std::forward<ReduceFunctor>(reduce),
|
| 269 |
+
ResultType(std::forward<InitialValueType>(initialValue)), options);
|
| 270 |
+
}
|
| 271 |
+
|
| 272 |
+
template <typename Iterator, typename MapFunctor, typename ReduceFunctor,
|
| 273 |
+
typename ResultType = typename QtPrivate::ReduceResultTypeHelper<ReduceFunctor>::type>
|
| 274 |
+
QFuture<ResultType> mappedReduced(QThreadPool *pool,
|
| 275 |
+
Iterator begin,
|
| 276 |
+
Iterator end,
|
| 277 |
+
MapFunctor &&map,
|
| 278 |
+
ReduceFunctor &&reduce,
|
| 279 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 280 |
+
| SequentialReduce))
|
| 281 |
+
{
|
| 282 |
+
return startMappedReduced<QtPrivate::MapResultType<Iterator, MapFunctor>, ResultType>(
|
| 283 |
+
pool, begin, end, std::forward<MapFunctor>(map), std::forward<ReduceFunctor>(reduce),
|
| 284 |
+
options);
|
| 285 |
+
}
|
| 286 |
+
|
| 287 |
+
template <typename Iterator, typename MapFunctor, typename ReduceFunctor,
|
| 288 |
+
typename ResultType = typename QtPrivate::ReduceResultTypeHelper<ReduceFunctor>::type>
|
| 289 |
+
QFuture<ResultType> mappedReduced(Iterator begin,
|
| 290 |
+
Iterator end,
|
| 291 |
+
MapFunctor &&map,
|
| 292 |
+
ReduceFunctor &&reduce,
|
| 293 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 294 |
+
| SequentialReduce))
|
| 295 |
+
{
|
| 296 |
+
return startMappedReduced<QtPrivate::MapResultType<Iterator, MapFunctor>, ResultType>
|
| 297 |
+
(QThreadPool::globalInstance(), begin, end, std::forward<MapFunctor>(map),
|
| 298 |
+
std::forward<ReduceFunctor>(reduce), options);
|
| 299 |
+
}
|
| 300 |
+
|
| 301 |
+
#ifdef Q_QDOC
|
| 302 |
+
template <typename Iterator, typename MapFunctor, typename ReduceFunctor, typename ResultType,
|
| 303 |
+
typename InitialValueType>
|
| 304 |
+
#else
|
| 305 |
+
template <typename Iterator, typename MapFunctor, typename ReduceFunctor,
|
| 306 |
+
typename ResultType = typename QtPrivate::ReduceResultTypeHelper<ReduceFunctor>::type,
|
| 307 |
+
typename InitialValueType,
|
| 308 |
+
std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
|
| 309 |
+
int> = 0>
|
| 310 |
+
#endif
|
| 311 |
+
QFuture<ResultType> mappedReduced(QThreadPool *pool,
|
| 312 |
+
Iterator begin,
|
| 313 |
+
Iterator end,
|
| 314 |
+
MapFunctor &&map,
|
| 315 |
+
ReduceFunctor &&reduce,
|
| 316 |
+
InitialValueType &&initialValue,
|
| 317 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 318 |
+
| SequentialReduce))
|
| 319 |
+
{
|
| 320 |
+
return startMappedReduced<QtPrivate::MapResultType<Iterator, MapFunctor>, ResultType>
|
| 321 |
+
(pool, begin, end, std::forward<MapFunctor>(map), std::forward<ReduceFunctor>(reduce),
|
| 322 |
+
ResultType(std::forward<InitialValueType>(initialValue)), options);
|
| 323 |
+
}
|
| 324 |
+
|
| 325 |
+
#ifdef Q_QDOC
|
| 326 |
+
template <typename Iterator, typename MapFunctor, typename ReduceFunctor, typename ResultType,
|
| 327 |
+
typename InitialValueType>
|
| 328 |
+
#else
|
| 329 |
+
template<typename Iterator, typename MapFunctor, typename ReduceFunctor,
|
| 330 |
+
std::enable_if_t<QtPrivate::isIterator_v<Iterator>, int> = 0,
|
| 331 |
+
typename ResultType = typename QtPrivate::ReduceResultTypeHelper<ReduceFunctor>::type,
|
| 332 |
+
typename InitialValueType,
|
| 333 |
+
std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
|
| 334 |
+
int> = 0>
|
| 335 |
+
#endif
|
| 336 |
+
QFuture<ResultType> mappedReduced(Iterator begin,
|
| 337 |
+
Iterator end,
|
| 338 |
+
MapFunctor &&map,
|
| 339 |
+
ReduceFunctor &&reduce,
|
| 340 |
+
InitialValueType &&initialValue,
|
| 341 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 342 |
+
| SequentialReduce))
|
| 343 |
+
{
|
| 344 |
+
return startMappedReduced<QtPrivate::MapResultType<Iterator, MapFunctor>, ResultType>
|
| 345 |
+
(QThreadPool::globalInstance(), begin, end, std::forward<MapFunctor>(map),
|
| 346 |
+
std::forward<ReduceFunctor>(reduce),
|
| 347 |
+
ResultType(std::forward<InitialValueType>(initialValue)), options);
|
| 348 |
+
}
|
| 349 |
+
|
| 350 |
+
// mapped() for sequences
|
| 351 |
+
template <typename Sequence, typename MapFunctor>
|
| 352 |
+
QFuture<QtPrivate::MapResultType<Sequence, MapFunctor>> mapped(
|
| 353 |
+
QThreadPool *pool,
|
| 354 |
+
Sequence &&sequence,
|
| 355 |
+
MapFunctor &&map)
|
| 356 |
+
{
|
| 357 |
+
return startMapped<QtPrivate::MapResultType<Sequence, MapFunctor>>(
|
| 358 |
+
pool, std::forward<Sequence>(sequence), std::forward<MapFunctor>(map));
|
| 359 |
+
}
|
| 360 |
+
|
| 361 |
+
template <typename Sequence, typename MapFunctor>
|
| 362 |
+
QFuture<QtPrivate::MapResultType<Sequence, MapFunctor>> mapped(
|
| 363 |
+
Sequence &&sequence,
|
| 364 |
+
MapFunctor &&map)
|
| 365 |
+
{
|
| 366 |
+
return startMapped<QtPrivate::MapResultType<Sequence, MapFunctor>>
|
| 367 |
+
(QThreadPool::globalInstance(), std::forward<Sequence>(sequence),
|
| 368 |
+
std::forward<MapFunctor>(map));
|
| 369 |
+
}
|
| 370 |
+
|
| 371 |
+
// mapped() for iterator ranges.
|
| 372 |
+
template <typename Iterator, typename MapFunctor>
|
| 373 |
+
QFuture<QtPrivate::MapResultType<Iterator, MapFunctor>> mapped(
|
| 374 |
+
QThreadPool *pool,
|
| 375 |
+
Iterator begin,
|
| 376 |
+
Iterator end,
|
| 377 |
+
MapFunctor &&map)
|
| 378 |
+
{
|
| 379 |
+
return startMapped<QtPrivate::MapResultType<Iterator, MapFunctor>>(
|
| 380 |
+
pool, begin, end, std::forward<MapFunctor>(map));
|
| 381 |
+
}
|
| 382 |
+
|
| 383 |
+
template <typename Iterator, typename MapFunctor>
|
| 384 |
+
QFuture<QtPrivate::MapResultType<Iterator, MapFunctor>> mapped(
|
| 385 |
+
Iterator begin,
|
| 386 |
+
Iterator end,
|
| 387 |
+
MapFunctor &&map)
|
| 388 |
+
{
|
| 389 |
+
return startMapped<QtPrivate::MapResultType<Iterator, MapFunctor>>
|
| 390 |
+
(QThreadPool::globalInstance(), begin, end, std::forward<MapFunctor>(map));
|
| 391 |
+
}
|
| 392 |
+
|
| 393 |
+
// blockingMap() for sequences
|
| 394 |
+
template <typename Sequence, typename MapFunctor>
|
| 395 |
+
void blockingMap(QThreadPool *pool, Sequence &&sequence, MapFunctor map)
|
| 396 |
+
{
|
| 397 |
+
QFuture<void> future =
|
| 398 |
+
startMap(pool, sequence.begin(), sequence.end(), std::forward<MapFunctor>(map));
|
| 399 |
+
future.waitForFinished();
|
| 400 |
+
}
|
| 401 |
+
|
| 402 |
+
template <typename Sequence, typename MapFunctor>
|
| 403 |
+
void blockingMap(Sequence &&sequence, MapFunctor &&map)
|
| 404 |
+
{
|
| 405 |
+
QFuture<void> future = startMap(QThreadPool::globalInstance(), sequence.begin(), sequence.end(),
|
| 406 |
+
std::forward<MapFunctor>(map));
|
| 407 |
+
future.waitForFinished();
|
| 408 |
+
}
|
| 409 |
+
|
| 410 |
+
// blockingMap() for iterator ranges
|
| 411 |
+
template <typename Iterator, typename MapFunctor>
|
| 412 |
+
void blockingMap(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor &&map)
|
| 413 |
+
{
|
| 414 |
+
QFuture<void> future = startMap(pool, begin, end, map);
|
| 415 |
+
future.waitForFinished();
|
| 416 |
+
}
|
| 417 |
+
|
| 418 |
+
template <typename Iterator, typename MapFunctor>
|
| 419 |
+
void blockingMap(Iterator begin, Iterator end, MapFunctor &&map)
|
| 420 |
+
{
|
| 421 |
+
QFuture<void> future = startMap(QThreadPool::globalInstance(), begin, end,
|
| 422 |
+
std::forward<MapFunctor>(map));
|
| 423 |
+
future.waitForFinished();
|
| 424 |
+
}
|
| 425 |
+
|
| 426 |
+
// blockingMappedReduced() for sequences
|
| 427 |
+
template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor>
|
| 428 |
+
ResultType blockingMappedReduced(QThreadPool *pool,
|
| 429 |
+
Sequence &&sequence,
|
| 430 |
+
MapFunctor &&map,
|
| 431 |
+
ReduceFunctor &&reduce,
|
| 432 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 433 |
+
| SequentialReduce))
|
| 434 |
+
{
|
| 435 |
+
QFuture<ResultType> future =
|
| 436 |
+
mappedReduced<ResultType>(pool, std::forward<Sequence>(sequence),
|
| 437 |
+
std::forward<MapFunctor>(map),
|
| 438 |
+
std::forward<ReduceFunctor>(reduce), options);
|
| 439 |
+
return future.takeResult();
|
| 440 |
+
}
|
| 441 |
+
|
| 442 |
+
template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor>
|
| 443 |
+
ResultType blockingMappedReduced(Sequence &&sequence,
|
| 444 |
+
MapFunctor &&map,
|
| 445 |
+
ReduceFunctor &&reduce,
|
| 446 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 447 |
+
| SequentialReduce))
|
| 448 |
+
{
|
| 449 |
+
QFuture<ResultType> future =
|
| 450 |
+
mappedReduced<ResultType>(std::forward<Sequence>(sequence),
|
| 451 |
+
std::forward<MapFunctor>(map),
|
| 452 |
+
std::forward<ReduceFunctor>(reduce), options);
|
| 453 |
+
return future.takeResult();
|
| 454 |
+
}
|
| 455 |
+
|
| 456 |
+
#ifdef Q_QDOC
|
| 457 |
+
template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor,
|
| 458 |
+
typename InitialValueType>
|
| 459 |
+
#else
|
| 460 |
+
template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor,
|
| 461 |
+
typename InitialValueType,
|
| 462 |
+
std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
|
| 463 |
+
int> = 0>
|
| 464 |
+
#endif
|
| 465 |
+
ResultType blockingMappedReduced(QThreadPool *pool,
|
| 466 |
+
Sequence &&sequence,
|
| 467 |
+
MapFunctor &&map,
|
| 468 |
+
ReduceFunctor &&reduce,
|
| 469 |
+
InitialValueType &&initialValue,
|
| 470 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 471 |
+
| SequentialReduce))
|
| 472 |
+
{
|
| 473 |
+
QFuture<ResultType> future = mappedReduced<ResultType>(
|
| 474 |
+
pool, std::forward<Sequence>(sequence), std::forward<MapFunctor>(map),
|
| 475 |
+
std::forward<ReduceFunctor>(reduce),
|
| 476 |
+
ResultType(std::forward<InitialValueType>(initialValue)), options);
|
| 477 |
+
return future.takeResult();
|
| 478 |
+
}
|
| 479 |
+
|
| 480 |
+
#ifdef Q_QDOC
|
| 481 |
+
template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor,
|
| 482 |
+
typename InitialValueType>
|
| 483 |
+
#else
|
| 484 |
+
template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor,
|
| 485 |
+
typename InitialValueType,
|
| 486 |
+
std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
|
| 487 |
+
int> = 0>
|
| 488 |
+
#endif
|
| 489 |
+
ResultType blockingMappedReduced(Sequence &&sequence,
|
| 490 |
+
MapFunctor &&map,
|
| 491 |
+
ReduceFunctor &&reduce,
|
| 492 |
+
InitialValueType &&initialValue,
|
| 493 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 494 |
+
| SequentialReduce))
|
| 495 |
+
{
|
| 496 |
+
QFuture<ResultType> future = mappedReduced<ResultType>(
|
| 497 |
+
std::forward<Sequence>(sequence), std::forward<MapFunctor>(map),
|
| 498 |
+
std::forward<ReduceFunctor>(reduce),
|
| 499 |
+
ResultType(std::forward<InitialValueType>(initialValue)), options);
|
| 500 |
+
return future.takeResult();
|
| 501 |
+
}
|
| 502 |
+
|
| 503 |
+
template <typename MapFunctor, typename ReduceFunctor, typename Sequence,
|
| 504 |
+
std::enable_if_t<QtPrivate::isInvocable<MapFunctor, Sequence>::value, int> = 0,
|
| 505 |
+
typename ResultType = typename QtPrivate::ReduceResultTypeHelper<ReduceFunctor>::type>
|
| 506 |
+
ResultType blockingMappedReduced(QThreadPool *pool,
|
| 507 |
+
Sequence &&sequence,
|
| 508 |
+
MapFunctor &&map,
|
| 509 |
+
ReduceFunctor &&reduce,
|
| 510 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 511 |
+
| SequentialReduce))
|
| 512 |
+
{
|
| 513 |
+
QFuture<ResultType> future =
|
| 514 |
+
mappedReduced<ResultType>(pool, std::forward<Sequence>(sequence),
|
| 515 |
+
std::forward<MapFunctor>(map),
|
| 516 |
+
std::forward<ReduceFunctor>(reduce), options);
|
| 517 |
+
return future.takeResult();
|
| 518 |
+
}
|
| 519 |
+
|
| 520 |
+
template <typename MapFunctor, typename ReduceFunctor, typename Sequence,
|
| 521 |
+
std::enable_if_t<QtPrivate::isInvocable<MapFunctor, Sequence>::value, int> = 0,
|
| 522 |
+
typename ResultType = typename QtPrivate::ReduceResultTypeHelper<ReduceFunctor>::type>
|
| 523 |
+
ResultType blockingMappedReduced(Sequence &&sequence,
|
| 524 |
+
MapFunctor &&map,
|
| 525 |
+
ReduceFunctor &&reduce,
|
| 526 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 527 |
+
| SequentialReduce))
|
| 528 |
+
{
|
| 529 |
+
QFuture<ResultType> future =
|
| 530 |
+
mappedReduced<ResultType>(std::forward<Sequence>(sequence),
|
| 531 |
+
std::forward<MapFunctor>(map),
|
| 532 |
+
std::forward<ReduceFunctor>(reduce), options);
|
| 533 |
+
return future.takeResult();
|
| 534 |
+
}
|
| 535 |
+
|
| 536 |
+
#ifdef Q_QDOC
|
| 537 |
+
template <typename MapFunctor, typename ReduceFunctor, typename Sequence, typename ResultType,
|
| 538 |
+
typename InitialValueType>
|
| 539 |
+
#else
|
| 540 |
+
template <typename MapFunctor, typename ReduceFunctor, typename Sequence, typename InitialValueType,
|
| 541 |
+
std::enable_if_t<QtPrivate::isInvocable<MapFunctor, Sequence>::value, int> = 0,
|
| 542 |
+
typename ResultType = typename QtPrivate::ReduceResultTypeHelper<ReduceFunctor>::type,
|
| 543 |
+
std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
|
| 544 |
+
int> = 0>
|
| 545 |
+
#endif
|
| 546 |
+
ResultType blockingMappedReduced(QThreadPool *pool,
|
| 547 |
+
Sequence &&sequence,
|
| 548 |
+
MapFunctor &&map,
|
| 549 |
+
ReduceFunctor &&reduce,
|
| 550 |
+
InitialValueType &&initialValue,
|
| 551 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 552 |
+
| SequentialReduce))
|
| 553 |
+
{
|
| 554 |
+
QFuture<ResultType> future = mappedReduced<ResultType>(
|
| 555 |
+
pool, std::forward<Sequence>(sequence), std::forward<MapFunctor>(map),
|
| 556 |
+
std::forward<ReduceFunctor>(reduce),
|
| 557 |
+
ResultType(std::forward<InitialValueType>(initialValue)), options);
|
| 558 |
+
return future.takeResult();
|
| 559 |
+
}
|
| 560 |
+
|
| 561 |
+
#ifdef Q_QDOC
|
| 562 |
+
template <typename MapFunctor, typename ReduceFunctor, typename Sequence, typename ResultType,
|
| 563 |
+
typename InitialValueType>
|
| 564 |
+
#else
|
| 565 |
+
template<typename MapFunctor, typename ReduceFunctor, typename Sequence, typename InitialValueType,
|
| 566 |
+
std::enable_if_t<QtPrivate::isInvocable<MapFunctor, Sequence>::value, int> = 0,
|
| 567 |
+
typename ResultType = typename QtPrivate::ReduceResultTypeHelper<ReduceFunctor>::type,
|
| 568 |
+
std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
|
| 569 |
+
int> = 0>
|
| 570 |
+
#endif
|
| 571 |
+
ResultType blockingMappedReduced(Sequence &&sequence,
|
| 572 |
+
MapFunctor &&map,
|
| 573 |
+
ReduceFunctor &&reduce,
|
| 574 |
+
InitialValueType &&initialValue,
|
| 575 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 576 |
+
| SequentialReduce))
|
| 577 |
+
{
|
| 578 |
+
QFuture<ResultType> future = mappedReduced<ResultType>(
|
| 579 |
+
std::forward<Sequence>(sequence), std::forward<MapFunctor>(map),
|
| 580 |
+
std::forward<ReduceFunctor>(reduce),
|
| 581 |
+
ResultType(std::forward<InitialValueType>(initialValue)), options);
|
| 582 |
+
return future.takeResult();
|
| 583 |
+
}
|
| 584 |
+
|
| 585 |
+
// blockingMappedReduced() for iterator ranges
|
| 586 |
+
template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor>
|
| 587 |
+
ResultType blockingMappedReduced(QThreadPool *pool,
|
| 588 |
+
Iterator begin,
|
| 589 |
+
Iterator end,
|
| 590 |
+
MapFunctor &&map,
|
| 591 |
+
ReduceFunctor &&reduce,
|
| 592 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 593 |
+
| SequentialReduce))
|
| 594 |
+
{
|
| 595 |
+
QFuture<ResultType> future =
|
| 596 |
+
mappedReduced<ResultType>(pool, begin, end, std::forward<MapFunctor>(map),
|
| 597 |
+
std::forward<ReduceFunctor>(reduce), options);
|
| 598 |
+
return future.takeResult();
|
| 599 |
+
}
|
| 600 |
+
|
| 601 |
+
template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor>
|
| 602 |
+
ResultType blockingMappedReduced(Iterator begin,
|
| 603 |
+
Iterator end,
|
| 604 |
+
MapFunctor &&map,
|
| 605 |
+
ReduceFunctor &&reduce,
|
| 606 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 607 |
+
| SequentialReduce))
|
| 608 |
+
{
|
| 609 |
+
QFuture<ResultType> future =
|
| 610 |
+
mappedReduced<ResultType>(begin, end, std::forward<MapFunctor>(map),
|
| 611 |
+
std::forward<ReduceFunctor>(reduce), options);
|
| 612 |
+
return future.takeResult();
|
| 613 |
+
}
|
| 614 |
+
|
| 615 |
+
#ifdef Q_QDOC
|
| 616 |
+
template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor,
|
| 617 |
+
typename InitialValueType>
|
| 618 |
+
#else
|
| 619 |
+
template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor,
|
| 620 |
+
typename InitialValueType,
|
| 621 |
+
std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
|
| 622 |
+
int> = 0>
|
| 623 |
+
#endif
|
| 624 |
+
ResultType blockingMappedReduced(QThreadPool *pool,
|
| 625 |
+
Iterator begin,
|
| 626 |
+
Iterator end,
|
| 627 |
+
MapFunctor &&map,
|
| 628 |
+
ReduceFunctor &&reduce,
|
| 629 |
+
InitialValueType &&initialValue,
|
| 630 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 631 |
+
| SequentialReduce))
|
| 632 |
+
{
|
| 633 |
+
QFuture<ResultType> future = mappedReduced<ResultType>(
|
| 634 |
+
pool, begin, end, std::forward<MapFunctor>(map), std::forward<ReduceFunctor>(reduce),
|
| 635 |
+
ResultType(std::forward<InitialValueType>(initialValue)),
|
| 636 |
+
options);
|
| 637 |
+
return future.takeResult();
|
| 638 |
+
}
|
| 639 |
+
|
| 640 |
+
#ifdef Q_QDOC
|
| 641 |
+
template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor,
|
| 642 |
+
typename InitialValueType>
|
| 643 |
+
#else
|
| 644 |
+
template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor,
|
| 645 |
+
typename InitialValueType,
|
| 646 |
+
std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
|
| 647 |
+
int> = 0>
|
| 648 |
+
#endif
|
| 649 |
+
ResultType blockingMappedReduced(Iterator begin,
|
| 650 |
+
Iterator end,
|
| 651 |
+
MapFunctor &&map,
|
| 652 |
+
ReduceFunctor &&reduce,
|
| 653 |
+
InitialValueType &&initialValue,
|
| 654 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 655 |
+
| SequentialReduce))
|
| 656 |
+
{
|
| 657 |
+
QFuture<ResultType> future = mappedReduced<ResultType>(
|
| 658 |
+
begin, end, std::forward<MapFunctor>(map), std::forward<ReduceFunctor>(reduce),
|
| 659 |
+
ResultType(std::forward<InitialValueType>(initialValue)),
|
| 660 |
+
options);
|
| 661 |
+
return future.takeResult();
|
| 662 |
+
}
|
| 663 |
+
|
| 664 |
+
template <typename Iterator, typename MapFunctor, typename ReduceFunctor,
|
| 665 |
+
typename ResultType = typename QtPrivate::ReduceResultTypeHelper<ReduceFunctor>::type>
|
| 666 |
+
ResultType blockingMappedReduced(QThreadPool *pool,
|
| 667 |
+
Iterator begin,
|
| 668 |
+
Iterator end,
|
| 669 |
+
MapFunctor &&map,
|
| 670 |
+
ReduceFunctor &&reduce,
|
| 671 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 672 |
+
| SequentialReduce))
|
| 673 |
+
{
|
| 674 |
+
QFuture<ResultType> future =
|
| 675 |
+
mappedReduced<ResultType>(pool, begin, end, std::forward<MapFunctor>(map),
|
| 676 |
+
std::forward<ReduceFunctor>(reduce), options);
|
| 677 |
+
return future.takeResult();
|
| 678 |
+
}
|
| 679 |
+
|
| 680 |
+
template <typename Iterator, typename MapFunctor, typename ReduceFunctor,
|
| 681 |
+
typename ResultType = typename QtPrivate::ReduceResultTypeHelper<ReduceFunctor>::type>
|
| 682 |
+
ResultType blockingMappedReduced(Iterator begin,
|
| 683 |
+
Iterator end,
|
| 684 |
+
MapFunctor &&map,
|
| 685 |
+
ReduceFunctor &&reduce,
|
| 686 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 687 |
+
| SequentialReduce))
|
| 688 |
+
{
|
| 689 |
+
QFuture<ResultType> future =
|
| 690 |
+
mappedReduced<ResultType>(begin, end, std::forward<MapFunctor>(map),
|
| 691 |
+
std::forward<ReduceFunctor>(reduce), options);
|
| 692 |
+
return future.takeResult();
|
| 693 |
+
}
|
| 694 |
+
|
| 695 |
+
#ifdef Q_QDOC
|
| 696 |
+
template <typename Iterator, typename MapFunctor, typename ReduceFunctor, typename ResultType,
|
| 697 |
+
typename InitialValueType>
|
| 698 |
+
#else
|
| 699 |
+
template <typename Iterator, typename MapFunctor, typename ReduceFunctor,
|
| 700 |
+
typename ResultType = typename QtPrivate::ReduceResultTypeHelper<ReduceFunctor>::type,
|
| 701 |
+
typename InitialValueType,
|
| 702 |
+
std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
|
| 703 |
+
int> = 0>
|
| 704 |
+
#endif
|
| 705 |
+
ResultType blockingMappedReduced(QThreadPool *pool,
|
| 706 |
+
Iterator begin,
|
| 707 |
+
Iterator end,
|
| 708 |
+
MapFunctor &&map,
|
| 709 |
+
ReduceFunctor &&reduce,
|
| 710 |
+
InitialValueType &&initialValue,
|
| 711 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 712 |
+
| SequentialReduce))
|
| 713 |
+
{
|
| 714 |
+
QFuture<ResultType> future = mappedReduced<ResultType>(
|
| 715 |
+
pool, begin, end, std::forward<MapFunctor>(map), std::forward<ReduceFunctor>(reduce),
|
| 716 |
+
ResultType(std::forward<InitialValueType>(initialValue)), options);
|
| 717 |
+
return future.takeResult();
|
| 718 |
+
}
|
| 719 |
+
|
| 720 |
+
#ifdef Q_QDOC
|
| 721 |
+
template <typename Iterator, typename MapFunctor, typename ReduceFunctor, typename ResultType,
|
| 722 |
+
typename InitialValueType>
|
| 723 |
+
#else
|
| 724 |
+
template <typename Iterator, typename MapFunctor, typename ReduceFunctor,
|
| 725 |
+
std::enable_if_t<QtPrivate::isIterator_v<Iterator>, int> = 0,
|
| 726 |
+
typename ResultType = typename QtPrivate::ReduceResultTypeHelper<ReduceFunctor>::type,
|
| 727 |
+
typename InitialValueType,
|
| 728 |
+
std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
|
| 729 |
+
int> = 0>
|
| 730 |
+
#endif
|
| 731 |
+
ResultType blockingMappedReduced(Iterator begin,
|
| 732 |
+
Iterator end,
|
| 733 |
+
MapFunctor &&map,
|
| 734 |
+
ReduceFunctor &&reduce,
|
| 735 |
+
InitialValueType &&initialValue,
|
| 736 |
+
ReduceOptions options = ReduceOptions(UnorderedReduce
|
| 737 |
+
| SequentialReduce))
|
| 738 |
+
{
|
| 739 |
+
QFuture<ResultType> future = mappedReduced<ResultType>(
|
| 740 |
+
begin, end, std::forward<MapFunctor>(map), std::forward<ReduceFunctor>(reduce),
|
| 741 |
+
ResultType(std::forward<InitialValueType>(initialValue)), options);
|
| 742 |
+
return future.takeResult();
|
| 743 |
+
}
|
| 744 |
+
|
| 745 |
+
// mapped() for sequences with a different putput sequence type.
|
| 746 |
+
template <typename OutputSequence, typename InputSequence, typename MapFunctor>
|
| 747 |
+
OutputSequence blockingMapped(QThreadPool *pool, InputSequence &&sequence, MapFunctor &&map)
|
| 748 |
+
{
|
| 749 |
+
return blockingMappedReduced<OutputSequence>(pool, std::forward<InputSequence>(sequence),
|
| 750 |
+
std::forward<MapFunctor>(map),
|
| 751 |
+
QtPrivate::PushBackWrapper(), OrderedReduce);
|
| 752 |
+
}
|
| 753 |
+
|
| 754 |
+
template <typename OutputSequence, typename InputSequence, typename MapFunctor>
|
| 755 |
+
OutputSequence blockingMapped(InputSequence &&sequence, MapFunctor &&map)
|
| 756 |
+
{
|
| 757 |
+
return blockingMappedReduced<OutputSequence>(
|
| 758 |
+
QThreadPool::globalInstance(), std::forward<InputSequence>(sequence),
|
| 759 |
+
std::forward<MapFunctor>(map), QtPrivate::PushBackWrapper(), OrderedReduce);
|
| 760 |
+
}
|
| 761 |
+
|
| 762 |
+
template <typename MapFunctor, typename InputSequence>
|
| 763 |
+
auto blockingMapped(QThreadPool *pool, InputSequence &&sequence, MapFunctor &&map)
|
| 764 |
+
{
|
| 765 |
+
using OutputSequence = typename QtPrivate::MapSequenceResultType<std::decay_t<InputSequence>,
|
| 766 |
+
MapFunctor>::ResultType;
|
| 767 |
+
return blockingMappedReduced<OutputSequence>(pool, std::forward<InputSequence>(sequence),
|
| 768 |
+
std::forward<MapFunctor>(map),
|
| 769 |
+
QtPrivate::PushBackWrapper(), OrderedReduce);
|
| 770 |
+
}
|
| 771 |
+
|
| 772 |
+
template <typename MapFunctor, typename InputSequence>
|
| 773 |
+
auto blockingMapped(InputSequence &&sequence, MapFunctor &&map)
|
| 774 |
+
{
|
| 775 |
+
using OutputSequence = typename QtPrivate::MapSequenceResultType<std::decay_t<InputSequence>,
|
| 776 |
+
MapFunctor>::ResultType;
|
| 777 |
+
return blockingMappedReduced<OutputSequence>(QThreadPool::globalInstance(),
|
| 778 |
+
std::forward<InputSequence>(sequence),
|
| 779 |
+
std::forward<MapFunctor>(map),
|
| 780 |
+
QtPrivate::PushBackWrapper(), OrderedReduce);
|
| 781 |
+
}
|
| 782 |
+
|
| 783 |
+
// mapped() for iterator ranges
|
| 784 |
+
template <typename Sequence, typename Iterator, typename MapFunctor>
|
| 785 |
+
Sequence blockingMapped(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor &&map)
|
| 786 |
+
{
|
| 787 |
+
return blockingMappedReduced<Sequence>(pool, begin, end, std::forward<MapFunctor>(map),
|
| 788 |
+
QtPrivate::PushBackWrapper(), OrderedReduce);
|
| 789 |
+
}
|
| 790 |
+
|
| 791 |
+
template <typename Sequence, typename Iterator, typename MapFunctor>
|
| 792 |
+
Sequence blockingMapped(Iterator begin, Iterator end, MapFunctor &&map)
|
| 793 |
+
{
|
| 794 |
+
return blockingMappedReduced<Sequence>(QThreadPool::globalInstance(), begin, end,
|
| 795 |
+
std::forward<MapFunctor>(map),
|
| 796 |
+
QtPrivate::PushBackWrapper(), OrderedReduce);
|
| 797 |
+
}
|
| 798 |
+
|
| 799 |
+
template <typename Iterator, typename MapFunctor>
|
| 800 |
+
auto blockingMapped(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor &&map)
|
| 801 |
+
{
|
| 802 |
+
using OutputSequence = QtPrivate::MapResultType<Iterator, MapFunctor>;
|
| 803 |
+
return blockingMappedReduced<OutputSequence>(pool, begin, end, std::forward<MapFunctor>(map),
|
| 804 |
+
QtPrivate::PushBackWrapper(), OrderedReduce);
|
| 805 |
+
}
|
| 806 |
+
|
| 807 |
+
template <typename Iterator, typename MapFunctor>
|
| 808 |
+
auto blockingMapped(Iterator begin, Iterator end, MapFunctor &&map)
|
| 809 |
+
{
|
| 810 |
+
using OutputSequence = QtPrivate::MapResultType<Iterator, MapFunctor>;
|
| 811 |
+
return blockingMappedReduced<OutputSequence>(QThreadPool::globalInstance(), begin, end,
|
| 812 |
+
std::forward<MapFunctor>(map),
|
| 813 |
+
QtPrivate::PushBackWrapper(), OrderedReduce);
|
| 814 |
+
}
|
| 815 |
+
|
| 816 |
+
} // namespace QtConcurrent
|
| 817 |
+
|
| 818 |
+
|
| 819 |
+
QT_END_NAMESPACE
|
| 820 |
+
|
| 821 |
+
#endif // QT_NO_CONCURRENT
|
| 822 |
+
|
| 823 |
+
#endif
|
qt/6.8.1/msvc2022_64/include/QtConcurrent/qtconcurrentmapkernel.h
ADDED
|
@@ -0,0 +1,327 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright (C) 2016 The Qt Company Ltd.
|
| 2 |
+
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
| 3 |
+
|
| 4 |
+
#ifndef QTCONCURRENT_MAPKERNEL_H
|
| 5 |
+
#define QTCONCURRENT_MAPKERNEL_H
|
| 6 |
+
|
| 7 |
+
#include <QtConcurrent/qtconcurrent_global.h>
|
| 8 |
+
|
| 9 |
+
#if !defined(QT_NO_CONCURRENT) || defined (Q_QDOC)
|
| 10 |
+
|
| 11 |
+
#include <QtConcurrent/qtconcurrentiteratekernel.h>
|
| 12 |
+
#include <QtConcurrent/qtconcurrentreducekernel.h>
|
| 13 |
+
#include <QtConcurrent/qtconcurrentfunctionwrappers.h>
|
| 14 |
+
|
| 15 |
+
QT_BEGIN_NAMESPACE
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
namespace QtConcurrent {
|
| 19 |
+
|
| 20 |
+
// map kernel, works with both parallel-for and parallel-while
|
| 21 |
+
template <typename Iterator, typename MapFunctor>
|
| 22 |
+
class MapKernel : public IterateKernel<Iterator, void>
|
| 23 |
+
{
|
| 24 |
+
MapFunctor map;
|
| 25 |
+
public:
|
| 26 |
+
typedef void ReturnType;
|
| 27 |
+
template <typename F = MapFunctor>
|
| 28 |
+
MapKernel(QThreadPool *pool, Iterator begin, Iterator end, F &&_map)
|
| 29 |
+
: IterateKernel<Iterator, void>(pool, begin, end), map(std::forward<F>(_map))
|
| 30 |
+
{ }
|
| 31 |
+
|
| 32 |
+
bool runIteration(Iterator it, int, void *) override
|
| 33 |
+
{
|
| 34 |
+
std::invoke(map, *it);
|
| 35 |
+
return false;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
bool runIterations(Iterator sequenceBeginIterator, int beginIndex, int endIndex, void *) override
|
| 39 |
+
{
|
| 40 |
+
Iterator it = sequenceBeginIterator;
|
| 41 |
+
std::advance(it, beginIndex);
|
| 42 |
+
for (int i = beginIndex; i < endIndex; ++i) {
|
| 43 |
+
runIteration(it, i, nullptr);
|
| 44 |
+
std::advance(it, 1);
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
return false;
|
| 48 |
+
}
|
| 49 |
+
};
|
| 50 |
+
|
| 51 |
+
template <typename ReducedResultType,
|
| 52 |
+
typename Iterator,
|
| 53 |
+
typename MapFunctor,
|
| 54 |
+
typename ReduceFunctor,
|
| 55 |
+
typename Reducer = ReduceKernel<ReduceFunctor,
|
| 56 |
+
ReducedResultType,
|
| 57 |
+
QtPrivate::MapResultType<Iterator, MapFunctor>>>
|
| 58 |
+
class MappedReducedKernel : public IterateKernel<Iterator, ReducedResultType>
|
| 59 |
+
{
|
| 60 |
+
ReducedResultType &reducedResult;
|
| 61 |
+
MapFunctor map;
|
| 62 |
+
ReduceFunctor reduce;
|
| 63 |
+
Reducer reducer;
|
| 64 |
+
using IntermediateResultsType = QtPrivate::MapResultType<Iterator, MapFunctor>;
|
| 65 |
+
|
| 66 |
+
public:
|
| 67 |
+
typedef ReducedResultType ReturnType;
|
| 68 |
+
|
| 69 |
+
template<typename F1 = MapFunctor, typename F2 = ReduceFunctor>
|
| 70 |
+
MappedReducedKernel(QThreadPool *pool, Iterator begin, Iterator end, F1 &&_map, F2 &&_reduce,
|
| 71 |
+
ReduceOptions reduceOptions)
|
| 72 |
+
: IterateKernel<Iterator, ReducedResultType>(pool, begin, end),
|
| 73 |
+
reducedResult(this->defaultValue.value),
|
| 74 |
+
map(std::forward<F1>(_map)),
|
| 75 |
+
reduce(std::forward<F2>(_reduce)),
|
| 76 |
+
reducer(pool, reduceOptions)
|
| 77 |
+
{ }
|
| 78 |
+
|
| 79 |
+
template<typename F1 = MapFunctor, typename F2 = ReduceFunctor>
|
| 80 |
+
MappedReducedKernel(QThreadPool *pool, Iterator begin, Iterator end, F1 &&_map, F2 &&_reduce,
|
| 81 |
+
ReducedResultType &&initialValue, ReduceOptions reduceOptions)
|
| 82 |
+
: IterateKernel<Iterator, ReducedResultType>(pool, begin, end,
|
| 83 |
+
std::forward<ReducedResultType>(initialValue)),
|
| 84 |
+
reducedResult(this->defaultValue.value),
|
| 85 |
+
map(std::forward<F1>(_map)),
|
| 86 |
+
reduce(std::forward<F2>(_reduce)),
|
| 87 |
+
reducer(pool, reduceOptions)
|
| 88 |
+
{
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
bool runIteration(Iterator it, int index, ReducedResultType *) override
|
| 92 |
+
{
|
| 93 |
+
IntermediateResults<IntermediateResultsType> results;
|
| 94 |
+
results.begin = index;
|
| 95 |
+
results.end = index + 1;
|
| 96 |
+
|
| 97 |
+
results.vector.append(std::invoke(map, *it));
|
| 98 |
+
reducer.runReduce(reduce, reducedResult, results);
|
| 99 |
+
return false;
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
bool runIterations(Iterator sequenceBeginIterator, int beginIndex, int endIndex, ReducedResultType *) override
|
| 103 |
+
{
|
| 104 |
+
IntermediateResults<IntermediateResultsType> results;
|
| 105 |
+
results.begin = beginIndex;
|
| 106 |
+
results.end = endIndex;
|
| 107 |
+
results.vector.reserve(endIndex - beginIndex);
|
| 108 |
+
|
| 109 |
+
Iterator it = sequenceBeginIterator;
|
| 110 |
+
std::advance(it, beginIndex);
|
| 111 |
+
for (int i = beginIndex; i < endIndex; ++i) {
|
| 112 |
+
results.vector.append(std::invoke(map, *it));
|
| 113 |
+
std::advance(it, 1);
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
reducer.runReduce(reduce, reducedResult, results);
|
| 117 |
+
return false;
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
void finish() override
|
| 121 |
+
{
|
| 122 |
+
reducer.finish(reduce, reducedResult);
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
bool shouldThrottleThread() override
|
| 126 |
+
{
|
| 127 |
+
return IterateKernel<Iterator, ReducedResultType>::shouldThrottleThread() || reducer.shouldThrottle();
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
bool shouldStartThread() override
|
| 131 |
+
{
|
| 132 |
+
return IterateKernel<Iterator, ReducedResultType>::shouldStartThread() && reducer.shouldStartThread();
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
typedef ReducedResultType ResultType;
|
| 136 |
+
ReducedResultType *result() override
|
| 137 |
+
{
|
| 138 |
+
return &reducedResult;
|
| 139 |
+
}
|
| 140 |
+
};
|
| 141 |
+
|
| 142 |
+
template <typename Iterator, typename MapFunctor>
|
| 143 |
+
class MappedEachKernel : public IterateKernel<Iterator, QtPrivate::MapResultType<Iterator, MapFunctor>>
|
| 144 |
+
{
|
| 145 |
+
MapFunctor map;
|
| 146 |
+
using T = QtPrivate::MapResultType<Iterator, MapFunctor>;
|
| 147 |
+
|
| 148 |
+
public:
|
| 149 |
+
template <typename F = MapFunctor>
|
| 150 |
+
MappedEachKernel(QThreadPool *pool, Iterator begin, Iterator end, F &&_map)
|
| 151 |
+
: IterateKernel<Iterator, T>(pool, begin, end), map(std::forward<F>(_map))
|
| 152 |
+
{ }
|
| 153 |
+
|
| 154 |
+
bool runIteration(Iterator it, int, T *result) override
|
| 155 |
+
{
|
| 156 |
+
*result = std::invoke(map, *it);
|
| 157 |
+
return true;
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
bool runIterations(Iterator sequenceBeginIterator, int beginIndex, int endIndex, T *results) override
|
| 161 |
+
{
|
| 162 |
+
|
| 163 |
+
Iterator it = sequenceBeginIterator;
|
| 164 |
+
std::advance(it, beginIndex);
|
| 165 |
+
for (int i = beginIndex; i < endIndex; ++i) {
|
| 166 |
+
runIteration(it, i, results + (i - beginIndex));
|
| 167 |
+
std::advance(it, 1);
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
return true;
|
| 171 |
+
}
|
| 172 |
+
};
|
| 173 |
+
|
| 174 |
+
//! [qtconcurrentmapkernel-1]
|
| 175 |
+
template <typename Iterator, typename Functor>
|
| 176 |
+
inline ThreadEngineStarter<void> startMap(QThreadPool *pool, Iterator begin,
|
| 177 |
+
Iterator end, Functor &&functor)
|
| 178 |
+
{
|
| 179 |
+
return startThreadEngine(new MapKernel<Iterator, std::decay_t<Functor>>(
|
| 180 |
+
pool, begin, end, std::forward<Functor>(functor)));
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
//! [qtconcurrentmapkernel-2]
|
| 184 |
+
template <typename T, typename Iterator, typename Functor>
|
| 185 |
+
inline ThreadEngineStarter<T> startMapped(QThreadPool *pool, Iterator begin,
|
| 186 |
+
Iterator end, Functor &&functor)
|
| 187 |
+
{
|
| 188 |
+
return startThreadEngine(new MappedEachKernel<Iterator, std::decay_t<Functor>>(
|
| 189 |
+
pool, begin, end, std::forward<Functor>(functor)));
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
/*
|
| 193 |
+
The SequnceHolder class is used to hold a reference to the
|
| 194 |
+
sequence we are working on.
|
| 195 |
+
*/
|
| 196 |
+
template <typename Sequence, typename Base, typename Functor>
|
| 197 |
+
struct SequenceHolder1 : private QtPrivate::SequenceHolder<Sequence>, public Base
|
| 198 |
+
{
|
| 199 |
+
template<typename S = Sequence, typename F = Functor>
|
| 200 |
+
SequenceHolder1(QThreadPool *pool, S &&_sequence, F &&functor)
|
| 201 |
+
: QtPrivate::SequenceHolder<Sequence>(std::forward<S>(_sequence)),
|
| 202 |
+
Base(pool, this->sequence.cbegin(), this->sequence.cend(), std::forward<F>(functor))
|
| 203 |
+
{ }
|
| 204 |
+
|
| 205 |
+
void finish() override
|
| 206 |
+
{
|
| 207 |
+
Base::finish();
|
| 208 |
+
// Clear the sequence to make sure all temporaries are destroyed
|
| 209 |
+
// before finished is signaled.
|
| 210 |
+
this->sequence = Sequence();
|
| 211 |
+
}
|
| 212 |
+
};
|
| 213 |
+
|
| 214 |
+
//! [qtconcurrentmapkernel-3]
|
| 215 |
+
template <typename T, typename Sequence, typename Functor>
|
| 216 |
+
inline ThreadEngineStarter<T> startMapped(QThreadPool *pool, Sequence &&sequence,
|
| 217 |
+
Functor &&functor)
|
| 218 |
+
{
|
| 219 |
+
using DecayedSequence = std::decay_t<Sequence>;
|
| 220 |
+
using DecayedFunctor = std::decay_t<Functor>;
|
| 221 |
+
using SequenceHolderType = SequenceHolder1<
|
| 222 |
+
DecayedSequence,
|
| 223 |
+
MappedEachKernel<typename DecayedSequence::const_iterator, DecayedFunctor>,
|
| 224 |
+
DecayedFunctor>;
|
| 225 |
+
|
| 226 |
+
return startThreadEngine(new SequenceHolderType(pool, std::forward<Sequence>(sequence),
|
| 227 |
+
std::forward<Functor>(functor)));
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
//! [qtconcurrentmapkernel-4]
|
| 231 |
+
template <typename IntermediateType, typename ResultType, typename Sequence, typename MapFunctor,
|
| 232 |
+
typename ReduceFunctor>
|
| 233 |
+
inline ThreadEngineStarter<ResultType> startMappedReduced(QThreadPool *pool,
|
| 234 |
+
Sequence &&sequence,
|
| 235 |
+
MapFunctor &&mapFunctor,
|
| 236 |
+
ReduceFunctor &&reduceFunctor,
|
| 237 |
+
ReduceOptions options)
|
| 238 |
+
{
|
| 239 |
+
using DecayedSequence = std::decay_t<Sequence>;
|
| 240 |
+
using DecayedMapFunctor = std::decay_t<MapFunctor>;
|
| 241 |
+
using DecayedReduceFunctor = std::decay_t<ReduceFunctor>;
|
| 242 |
+
using Iterator = typename DecayedSequence::const_iterator;
|
| 243 |
+
using Reducer = ReduceKernel<DecayedReduceFunctor, ResultType, IntermediateType>;
|
| 244 |
+
using MappedReduceType = MappedReducedKernel<ResultType, Iterator, DecayedMapFunctor,
|
| 245 |
+
DecayedReduceFunctor, Reducer>;
|
| 246 |
+
using SequenceHolderType = SequenceHolder2<DecayedSequence, MappedReduceType, DecayedMapFunctor,
|
| 247 |
+
DecayedReduceFunctor>;
|
| 248 |
+
return startThreadEngine(new SequenceHolderType(pool, std::forward<Sequence>(sequence),
|
| 249 |
+
std::forward<MapFunctor>(mapFunctor),
|
| 250 |
+
std::forward<ReduceFunctor>(reduceFunctor),
|
| 251 |
+
options));
|
| 252 |
+
}
|
| 253 |
+
|
| 254 |
+
//! [qtconcurrentmapkernel-5]
|
| 255 |
+
template <typename IntermediateType, typename ResultType, typename Iterator, typename MapFunctor,
|
| 256 |
+
typename ReduceFunctor>
|
| 257 |
+
inline ThreadEngineStarter<ResultType> startMappedReduced(QThreadPool *pool,
|
| 258 |
+
Iterator begin,
|
| 259 |
+
Iterator end,
|
| 260 |
+
MapFunctor &&mapFunctor,
|
| 261 |
+
ReduceFunctor &&reduceFunctor,
|
| 262 |
+
ReduceOptions options)
|
| 263 |
+
{
|
| 264 |
+
using Reducer =
|
| 265 |
+
ReduceKernel<std::decay_t<ReduceFunctor>, std::decay_t<ResultType>, IntermediateType>;
|
| 266 |
+
using MappedReduceType = MappedReducedKernel<ResultType, Iterator, std::decay_t<MapFunctor>,
|
| 267 |
+
std::decay_t<ReduceFunctor>, Reducer>;
|
| 268 |
+
return startThreadEngine(new MappedReduceType(pool, begin, end,
|
| 269 |
+
std::forward<MapFunctor>(mapFunctor),
|
| 270 |
+
std::forward<ReduceFunctor>(reduceFunctor),
|
| 271 |
+
options));
|
| 272 |
+
}
|
| 273 |
+
|
| 274 |
+
//! [qtconcurrentmapkernel-6]
|
| 275 |
+
template <typename IntermediateType, typename ResultType, typename Sequence, typename MapFunctor,
|
| 276 |
+
typename ReduceFunctor>
|
| 277 |
+
inline ThreadEngineStarter<ResultType> startMappedReduced(QThreadPool *pool,
|
| 278 |
+
Sequence &&sequence,
|
| 279 |
+
MapFunctor &&mapFunctor,
|
| 280 |
+
ReduceFunctor &&reduceFunctor,
|
| 281 |
+
ResultType &&initialValue,
|
| 282 |
+
ReduceOptions options)
|
| 283 |
+
{
|
| 284 |
+
using DecayedSequence = std::decay_t<Sequence>;
|
| 285 |
+
using DecayedMapFunctor = std::decay_t<MapFunctor>;
|
| 286 |
+
using DecayedReduceFunctor = std::decay_t<ReduceFunctor>;
|
| 287 |
+
using Iterator = typename DecayedSequence::const_iterator;
|
| 288 |
+
using Reducer = ReduceKernel<DecayedReduceFunctor, ResultType, IntermediateType>;
|
| 289 |
+
using MappedReduceType = MappedReducedKernel<ResultType, Iterator, DecayedMapFunctor,
|
| 290 |
+
DecayedReduceFunctor, Reducer>;
|
| 291 |
+
using SequenceHolderType = SequenceHolder2<DecayedSequence, MappedReduceType, DecayedMapFunctor,
|
| 292 |
+
DecayedReduceFunctor>;
|
| 293 |
+
return startThreadEngine(
|
| 294 |
+
new SequenceHolderType(pool, std::forward<Sequence>(sequence),
|
| 295 |
+
std::forward<MapFunctor>(mapFunctor),
|
| 296 |
+
std::forward<ReduceFunctor>(reduceFunctor),
|
| 297 |
+
std::forward<ResultType>(initialValue), options));
|
| 298 |
+
}
|
| 299 |
+
|
| 300 |
+
//! [qtconcurrentmapkernel-7]
|
| 301 |
+
template <typename IntermediateType, typename ResultType, typename Iterator, typename MapFunctor,
|
| 302 |
+
typename ReduceFunctor>
|
| 303 |
+
inline ThreadEngineStarter<ResultType> startMappedReduced(QThreadPool *pool,
|
| 304 |
+
Iterator begin,
|
| 305 |
+
Iterator end,
|
| 306 |
+
MapFunctor &&mapFunctor,
|
| 307 |
+
ReduceFunctor &&reduceFunctor,
|
| 308 |
+
ResultType &&initialValue,
|
| 309 |
+
ReduceOptions options)
|
| 310 |
+
{
|
| 311 |
+
using Reducer = ReduceKernel<std::decay_t<ReduceFunctor>, ResultType, IntermediateType>;
|
| 312 |
+
using MappedReduceType = MappedReducedKernel<ResultType, Iterator, std::decay_t<MapFunctor>,
|
| 313 |
+
std::decay_t<ReduceFunctor>, Reducer>;
|
| 314 |
+
return startThreadEngine(new MappedReduceType(pool, begin, end,
|
| 315 |
+
std::forward<MapFunctor>(mapFunctor),
|
| 316 |
+
std::forward<ReduceFunctor>(reduceFunctor),
|
| 317 |
+
std::forward<ResultType>(initialValue), options));
|
| 318 |
+
}
|
| 319 |
+
|
| 320 |
+
} // namespace QtConcurrent
|
| 321 |
+
|
| 322 |
+
|
| 323 |
+
QT_END_NAMESPACE
|
| 324 |
+
|
| 325 |
+
#endif // QT_NO_CONCURRENT
|
| 326 |
+
|
| 327 |
+
#endif
|
qt/6.8.1/msvc2022_64/include/QtConcurrent/qtconcurrentmedian.h
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright (C) 2016 The Qt Company Ltd.
|
| 2 |
+
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
| 3 |
+
|
| 4 |
+
#ifndef QTCONCURRENT_MEDIAN_H
|
| 5 |
+
#define QTCONCURRENT_MEDIAN_H
|
| 6 |
+
|
| 7 |
+
#include <QtConcurrent/qtconcurrent_global.h>
|
| 8 |
+
|
| 9 |
+
#if !defined(QT_NO_CONCURRENT) || defined(Q_QDOC)
|
| 10 |
+
|
| 11 |
+
#include <algorithm>
|
| 12 |
+
#include <cstring>
|
| 13 |
+
|
| 14 |
+
QT_BEGIN_NAMESPACE
|
| 15 |
+
|
| 16 |
+
namespace QtConcurrent {
|
| 17 |
+
|
| 18 |
+
class Median
|
| 19 |
+
{
|
| 20 |
+
public:
|
| 21 |
+
enum { BufferSize = 7 };
|
| 22 |
+
|
| 23 |
+
Median()
|
| 24 |
+
: currentMedian(), currentIndex(0), valid(false), dirty(true)
|
| 25 |
+
{
|
| 26 |
+
std::fill_n(values, static_cast<int>(BufferSize), 0.0);
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
void reset()
|
| 30 |
+
{
|
| 31 |
+
std::fill_n(values, static_cast<int>(BufferSize), 0.0);
|
| 32 |
+
currentIndex = 0;
|
| 33 |
+
valid = false;
|
| 34 |
+
dirty = true;
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
void addValue(double value)
|
| 38 |
+
{
|
| 39 |
+
++currentIndex;
|
| 40 |
+
if (currentIndex == BufferSize) {
|
| 41 |
+
currentIndex = 0;
|
| 42 |
+
valid = true;
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
// Only update the cached median value when we have to, that
|
| 46 |
+
// is when the new value is on then other side of the median
|
| 47 |
+
// compared to the current value at the index.
|
| 48 |
+
const double currentIndexValue = values[currentIndex];
|
| 49 |
+
if ((currentIndexValue > currentMedian && currentMedian > value)
|
| 50 |
+
|| (currentMedian > currentIndexValue && value > currentMedian)) {
|
| 51 |
+
dirty = true;
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
values[currentIndex] = value;
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
bool isMedianValid() const
|
| 58 |
+
{
|
| 59 |
+
return valid;
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
double median()
|
| 63 |
+
{
|
| 64 |
+
if (dirty) {
|
| 65 |
+
dirty = false;
|
| 66 |
+
|
| 67 |
+
double sorted[BufferSize];
|
| 68 |
+
::memcpy(&sorted, &values, sizeof(sorted));
|
| 69 |
+
std::sort(sorted, sorted + static_cast<int>(BufferSize));
|
| 70 |
+
currentMedian = sorted[BufferSize / 2];
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
return currentMedian;
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
private:
|
| 77 |
+
double values[BufferSize];
|
| 78 |
+
double currentMedian;
|
| 79 |
+
int currentIndex;
|
| 80 |
+
bool valid;
|
| 81 |
+
bool dirty;
|
| 82 |
+
};
|
| 83 |
+
|
| 84 |
+
} // namespace QtConcurrent
|
| 85 |
+
|
| 86 |
+
QT_END_NAMESPACE
|
| 87 |
+
|
| 88 |
+
#endif // QT_NO_CONCURRENT
|
| 89 |
+
|
| 90 |
+
#endif
|
qt/6.8.1/msvc2022_64/include/QtConcurrent/qtconcurrentreducekernel.h
ADDED
|
@@ -0,0 +1,237 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright (C) 2016 The Qt Company Ltd.
|
| 2 |
+
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
| 3 |
+
|
| 4 |
+
#ifndef QTCONCURRENT_REDUCEKERNEL_H
|
| 5 |
+
#define QTCONCURRENT_REDUCEKERNEL_H
|
| 6 |
+
|
| 7 |
+
#include <QtConcurrent/qtconcurrent_global.h>
|
| 8 |
+
|
| 9 |
+
#if !defined(QT_NO_CONCURRENT) || defined(Q_QDOC)
|
| 10 |
+
|
| 11 |
+
#include <QtCore/qatomic.h>
|
| 12 |
+
#include <QtCore/qlist.h>
|
| 13 |
+
#include <QtCore/qmap.h>
|
| 14 |
+
#include <QtCore/qmutex.h>
|
| 15 |
+
#include <QtCore/qthread.h>
|
| 16 |
+
#include <QtCore/qthreadpool.h>
|
| 17 |
+
|
| 18 |
+
#include <mutex>
|
| 19 |
+
|
| 20 |
+
QT_BEGIN_NAMESPACE
|
| 21 |
+
|
| 22 |
+
namespace QtPrivate {
|
| 23 |
+
|
| 24 |
+
template<typename Sequence>
|
| 25 |
+
struct SequenceHolder
|
| 26 |
+
{
|
| 27 |
+
SequenceHolder(const Sequence &s) : sequence(s) { }
|
| 28 |
+
SequenceHolder(Sequence &&s) : sequence(std::move(s)) { }
|
| 29 |
+
Sequence sequence;
|
| 30 |
+
};
|
| 31 |
+
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
namespace QtConcurrent {
|
| 35 |
+
|
| 36 |
+
/*
|
| 37 |
+
The ReduceQueueStartLimit and ReduceQueueThrottleLimit constants
|
| 38 |
+
limit the reduce queue size for MapReduce. When the number of
|
| 39 |
+
reduce blocks in the queue exceeds ReduceQueueStartLimit,
|
| 40 |
+
MapReduce won't start any new threads, and when it exceeds
|
| 41 |
+
ReduceQueueThrottleLimit running threads will be stopped.
|
| 42 |
+
*/
|
| 43 |
+
#ifdef Q_QDOC
|
| 44 |
+
enum ReduceQueueLimits {
|
| 45 |
+
ReduceQueueStartLimit = 20,
|
| 46 |
+
ReduceQueueThrottleLimit = 30
|
| 47 |
+
};
|
| 48 |
+
#else
|
| 49 |
+
enum {
|
| 50 |
+
ReduceQueueStartLimit = 20,
|
| 51 |
+
ReduceQueueThrottleLimit = 30
|
| 52 |
+
};
|
| 53 |
+
#endif
|
| 54 |
+
|
| 55 |
+
// IntermediateResults holds a block of intermediate results from a
|
| 56 |
+
// map or filter functor. The begin/end offsets indicates the origin
|
| 57 |
+
// and range of the block.
|
| 58 |
+
template <typename T>
|
| 59 |
+
class IntermediateResults
|
| 60 |
+
{
|
| 61 |
+
public:
|
| 62 |
+
int begin, end;
|
| 63 |
+
QList<T> vector;
|
| 64 |
+
};
|
| 65 |
+
|
| 66 |
+
enum ReduceOption {
|
| 67 |
+
UnorderedReduce = 0x1,
|
| 68 |
+
OrderedReduce = 0x2,
|
| 69 |
+
SequentialReduce = 0x4
|
| 70 |
+
// ParallelReduce = 0x8
|
| 71 |
+
};
|
| 72 |
+
Q_DECLARE_FLAGS(ReduceOptions, ReduceOption)
|
| 73 |
+
#ifndef Q_QDOC
|
| 74 |
+
Q_DECLARE_OPERATORS_FOR_FLAGS(ReduceOptions)
|
| 75 |
+
#endif
|
| 76 |
+
// supports both ordered and out-of-order reduction
|
| 77 |
+
template <typename ReduceFunctor, typename ReduceResultType, typename T>
|
| 78 |
+
class ReduceKernel
|
| 79 |
+
{
|
| 80 |
+
typedef QMap<int, IntermediateResults<T> > ResultsMap;
|
| 81 |
+
|
| 82 |
+
const ReduceOptions reduceOptions;
|
| 83 |
+
|
| 84 |
+
QMutex mutex;
|
| 85 |
+
int progress, resultsMapSize;
|
| 86 |
+
const int threadCount;
|
| 87 |
+
ResultsMap resultsMap;
|
| 88 |
+
|
| 89 |
+
bool canReduce(int begin) const
|
| 90 |
+
{
|
| 91 |
+
return (((reduceOptions & UnorderedReduce)
|
| 92 |
+
&& progress == 0)
|
| 93 |
+
|| ((reduceOptions & OrderedReduce)
|
| 94 |
+
&& progress == begin));
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
void reduceResult(ReduceFunctor &reduce,
|
| 98 |
+
ReduceResultType &r,
|
| 99 |
+
const IntermediateResults<T> &result)
|
| 100 |
+
{
|
| 101 |
+
for (int i = 0; i < result.vector.size(); ++i) {
|
| 102 |
+
std::invoke(reduce, r, result.vector.at(i));
|
| 103 |
+
}
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
void reduceResults(ReduceFunctor &reduce,
|
| 107 |
+
ReduceResultType &r,
|
| 108 |
+
ResultsMap &map)
|
| 109 |
+
{
|
| 110 |
+
typename ResultsMap::iterator it = map.begin();
|
| 111 |
+
while (it != map.end()) {
|
| 112 |
+
reduceResult(reduce, r, it.value());
|
| 113 |
+
++it;
|
| 114 |
+
}
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
public:
|
| 118 |
+
ReduceKernel(QThreadPool *pool, ReduceOptions _reduceOptions)
|
| 119 |
+
: reduceOptions(_reduceOptions), progress(0), resultsMapSize(0),
|
| 120 |
+
threadCount(std::max(pool->maxThreadCount(), 1))
|
| 121 |
+
{ }
|
| 122 |
+
|
| 123 |
+
void runReduce(ReduceFunctor &reduce,
|
| 124 |
+
ReduceResultType &r,
|
| 125 |
+
const IntermediateResults<T> &result)
|
| 126 |
+
{
|
| 127 |
+
std::unique_lock<QMutex> locker(mutex);
|
| 128 |
+
if (!canReduce(result.begin)) {
|
| 129 |
+
++resultsMapSize;
|
| 130 |
+
resultsMap.insert(result.begin, result);
|
| 131 |
+
return;
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
if (reduceOptions & UnorderedReduce) {
|
| 135 |
+
// UnorderedReduce
|
| 136 |
+
progress = -1;
|
| 137 |
+
|
| 138 |
+
// reduce this result
|
| 139 |
+
locker.unlock();
|
| 140 |
+
reduceResult(reduce, r, result);
|
| 141 |
+
locker.lock();
|
| 142 |
+
|
| 143 |
+
// reduce all stored results as well
|
| 144 |
+
while (!resultsMap.isEmpty()) {
|
| 145 |
+
ResultsMap resultsMapCopy = resultsMap;
|
| 146 |
+
resultsMap.clear();
|
| 147 |
+
|
| 148 |
+
locker.unlock();
|
| 149 |
+
reduceResults(reduce, r, resultsMapCopy);
|
| 150 |
+
locker.lock();
|
| 151 |
+
|
| 152 |
+
resultsMapSize -= resultsMapCopy.size();
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
progress = 0;
|
| 156 |
+
} else {
|
| 157 |
+
// reduce this result
|
| 158 |
+
locker.unlock();
|
| 159 |
+
reduceResult(reduce, r, result);
|
| 160 |
+
locker.lock();
|
| 161 |
+
|
| 162 |
+
// OrderedReduce
|
| 163 |
+
progress += result.end - result.begin;
|
| 164 |
+
|
| 165 |
+
// reduce as many other results as possible
|
| 166 |
+
typename ResultsMap::iterator it = resultsMap.begin();
|
| 167 |
+
while (it != resultsMap.end()) {
|
| 168 |
+
if (it.value().begin != progress)
|
| 169 |
+
break;
|
| 170 |
+
|
| 171 |
+
locker.unlock();
|
| 172 |
+
reduceResult(reduce, r, it.value());
|
| 173 |
+
locker.lock();
|
| 174 |
+
|
| 175 |
+
--resultsMapSize;
|
| 176 |
+
progress += it.value().end - it.value().begin;
|
| 177 |
+
it = resultsMap.erase(it);
|
| 178 |
+
}
|
| 179 |
+
}
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
// final reduction
|
| 183 |
+
void finish(ReduceFunctor &reduce, ReduceResultType &r)
|
| 184 |
+
{
|
| 185 |
+
reduceResults(reduce, r, resultsMap);
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
inline bool shouldThrottle()
|
| 189 |
+
{
|
| 190 |
+
std::lock_guard<QMutex> locker(mutex);
|
| 191 |
+
return (resultsMapSize > (ReduceQueueThrottleLimit * threadCount));
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
inline bool shouldStartThread()
|
| 195 |
+
{
|
| 196 |
+
std::lock_guard<QMutex> locker(mutex);
|
| 197 |
+
return (resultsMapSize <= (ReduceQueueStartLimit * threadCount));
|
| 198 |
+
}
|
| 199 |
+
};
|
| 200 |
+
|
| 201 |
+
template <typename Sequence, typename Base, typename Functor1, typename Functor2>
|
| 202 |
+
struct SequenceHolder2 : private QtPrivate::SequenceHolder<Sequence>, public Base
|
| 203 |
+
{
|
| 204 |
+
template<typename S = Sequence, typename F1 = Functor1, typename F2 = Functor2>
|
| 205 |
+
SequenceHolder2(QThreadPool *pool, S &&_sequence, F1 &&functor1, F2 &&functor2,
|
| 206 |
+
ReduceOptions reduceOptions)
|
| 207 |
+
: QtPrivate::SequenceHolder<Sequence>(std::forward<S>(_sequence)),
|
| 208 |
+
Base(pool, this->sequence.cbegin(), this->sequence.cend(),
|
| 209 |
+
std::forward<F1>(functor1), std::forward<F2>(functor2), reduceOptions)
|
| 210 |
+
{ }
|
| 211 |
+
|
| 212 |
+
template<typename InitialValueType, typename S = Sequence,
|
| 213 |
+
typename F1 = Functor1, typename F2 = Functor2>
|
| 214 |
+
SequenceHolder2(QThreadPool *pool, S &&_sequence, F1 &&functor1, F2 &&functor2,
|
| 215 |
+
InitialValueType &&initialValue, ReduceOptions reduceOptions)
|
| 216 |
+
: QtPrivate::SequenceHolder<Sequence>(std::forward<S>(_sequence)),
|
| 217 |
+
Base(pool, this->sequence.cbegin(), this->sequence.cend(),
|
| 218 |
+
std::forward<F1>(functor1), std::forward<F2>(functor2),
|
| 219 |
+
std::forward<InitialValueType>(initialValue), reduceOptions)
|
| 220 |
+
{ }
|
| 221 |
+
|
| 222 |
+
void finish() override
|
| 223 |
+
{
|
| 224 |
+
Base::finish();
|
| 225 |
+
// Clear the sequence to make sure all temporaries are destroyed
|
| 226 |
+
// before finished is signaled.
|
| 227 |
+
this->sequence = Sequence();
|
| 228 |
+
}
|
| 229 |
+
};
|
| 230 |
+
|
| 231 |
+
} // namespace QtConcurrent
|
| 232 |
+
|
| 233 |
+
QT_END_NAMESPACE
|
| 234 |
+
|
| 235 |
+
#endif // QT_NO_CONCURRENT
|
| 236 |
+
|
| 237 |
+
#endif
|
qt/6.8.1/msvc2022_64/include/QtConcurrent/qtconcurrentrun.h
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright (C) 2016 The Qt Company Ltd.
|
| 2 |
+
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
| 3 |
+
|
| 4 |
+
#ifndef QTCONCURRENT_RUN_H
|
| 5 |
+
#define QTCONCURRENT_RUN_H
|
| 6 |
+
|
| 7 |
+
#if 0
|
| 8 |
+
#pragma qt_class(QtConcurrentRun)
|
| 9 |
+
#endif
|
| 10 |
+
|
| 11 |
+
#include <QtConcurrent/qtconcurrentcompilertest.h>
|
| 12 |
+
|
| 13 |
+
#if !defined(QT_NO_CONCURRENT) || defined(Q_QDOC)
|
| 14 |
+
|
| 15 |
+
#include <QtConcurrent/qtconcurrentrunbase.h>
|
| 16 |
+
#include <QtConcurrent/qtconcurrentstoredfunctioncall.h>
|
| 17 |
+
|
| 18 |
+
QT_BEGIN_NAMESPACE
|
| 19 |
+
|
| 20 |
+
#ifdef Q_QDOC
|
| 21 |
+
|
| 22 |
+
typedef int Function;
|
| 23 |
+
|
| 24 |
+
namespace QtConcurrent {
|
| 25 |
+
|
| 26 |
+
template <typename T>
|
| 27 |
+
QFuture<T> run(Function function, ...);
|
| 28 |
+
|
| 29 |
+
template <typename T>
|
| 30 |
+
QFuture<T> run(QThreadPool *pool, Function function, ...);
|
| 31 |
+
|
| 32 |
+
} // namespace QtConcurrent
|
| 33 |
+
|
| 34 |
+
#else
|
| 35 |
+
|
| 36 |
+
namespace QtConcurrent {
|
| 37 |
+
|
| 38 |
+
#define QTCONCURRENT_RUN_NODISCARD \
|
| 39 |
+
Q_NODISCARD_X("Use QThreadPool::start(Callable&&) if you don't need the returned QFuture")
|
| 40 |
+
|
| 41 |
+
template <class Function, class ...Args>
|
| 42 |
+
QTCONCURRENT_RUN_NODISCARD
|
| 43 |
+
auto run(QThreadPool *pool, Function &&f, Args &&...args)
|
| 44 |
+
{
|
| 45 |
+
DecayedTuple<Function, Args...> tuple { std::forward<Function>(f),
|
| 46 |
+
std::forward<Args>(args)... };
|
| 47 |
+
return TaskResolver<std::decay_t<Function>, std::decay_t<Args>...>::run(
|
| 48 |
+
std::move(tuple), TaskStartParameters { pool });
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
template <class Function, class ...Args>
|
| 52 |
+
QTCONCURRENT_RUN_NODISCARD
|
| 53 |
+
auto run(QThreadPool *pool, std::reference_wrapper<const Function> &&functionWrapper,
|
| 54 |
+
Args &&...args)
|
| 55 |
+
{
|
| 56 |
+
return run(pool, std::forward<const Function>(functionWrapper.get()),
|
| 57 |
+
std::forward<Args>(args)...);
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
template <class Function, class ...Args>
|
| 61 |
+
QTCONCURRENT_RUN_NODISCARD
|
| 62 |
+
auto run(Function &&f, Args &&...args)
|
| 63 |
+
{
|
| 64 |
+
return run(QThreadPool::globalInstance(), std::forward<Function>(f),
|
| 65 |
+
std::forward<Args>(args)...);
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
// overload with a Promise Type hint, takes thread pool
|
| 69 |
+
template <class PromiseType, class Function, class ...Args>
|
| 70 |
+
QTCONCURRENT_RUN_NODISCARD
|
| 71 |
+
auto run(QThreadPool *pool, Function &&f, Args &&...args)
|
| 72 |
+
{
|
| 73 |
+
return (new StoredFunctionCallWithPromise<Function, PromiseType, Args...>(
|
| 74 |
+
std::forward<Function>(f), std::forward<Args>(args)...))->start(pool);
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
// overload with a Promise Type hint, uses global thread pool
|
| 78 |
+
template <class PromiseType, class Function, class ...Args>
|
| 79 |
+
QTCONCURRENT_RUN_NODISCARD
|
| 80 |
+
auto run(Function &&f, Args &&...args)
|
| 81 |
+
{
|
| 82 |
+
return run<PromiseType>(QThreadPool::globalInstance(), std::forward<Function>(f),
|
| 83 |
+
std::forward<Args>(args)...);
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
#undef QTCONCURRENT_RUN_NODISCARD
|
| 87 |
+
|
| 88 |
+
} //namespace QtConcurrent
|
| 89 |
+
|
| 90 |
+
#endif // Q_QDOC
|
| 91 |
+
|
| 92 |
+
QT_END_NAMESPACE
|
| 93 |
+
|
| 94 |
+
#endif // QT_NO_CONCURRENT
|
| 95 |
+
|
| 96 |
+
#endif
|
qt/6.8.1/msvc2022_64/include/QtConcurrent/qtconcurrentrunbase.h
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright (C) 2016 The Qt Company Ltd.
|
| 2 |
+
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
| 3 |
+
|
| 4 |
+
#ifndef QTCONCURRENT_RUNBASE_H
|
| 5 |
+
#define QTCONCURRENT_RUNBASE_H
|
| 6 |
+
|
| 7 |
+
#include <QtConcurrent/qtconcurrent_global.h>
|
| 8 |
+
|
| 9 |
+
#ifndef QT_NO_CONCURRENT
|
| 10 |
+
|
| 11 |
+
#include <QtCore/qfuture.h>
|
| 12 |
+
#include <QtCore/qrunnable.h>
|
| 13 |
+
#include <QtCore/qthreadpool.h>
|
| 14 |
+
|
| 15 |
+
#include <type_traits>
|
| 16 |
+
#include <utility>
|
| 17 |
+
|
| 18 |
+
QT_BEGIN_NAMESPACE
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
#ifndef Q_QDOC
|
| 22 |
+
|
| 23 |
+
namespace QtConcurrent {
|
| 24 |
+
|
| 25 |
+
template <typename T>
|
| 26 |
+
struct SelectSpecialization
|
| 27 |
+
{
|
| 28 |
+
template <class Normal, class Void>
|
| 29 |
+
struct Type { typedef Normal type; };
|
| 30 |
+
};
|
| 31 |
+
|
| 32 |
+
template <>
|
| 33 |
+
struct SelectSpecialization<void>
|
| 34 |
+
{
|
| 35 |
+
template <class Normal, class Void>
|
| 36 |
+
struct Type { typedef Void type; };
|
| 37 |
+
};
|
| 38 |
+
|
| 39 |
+
struct TaskStartParameters
|
| 40 |
+
{
|
| 41 |
+
QThreadPool *threadPool = QThreadPool::globalInstance();
|
| 42 |
+
int priority = 0;
|
| 43 |
+
};
|
| 44 |
+
|
| 45 |
+
template <typename T>
|
| 46 |
+
class RunFunctionTaskBase : public QRunnable
|
| 47 |
+
{
|
| 48 |
+
public:
|
| 49 |
+
QFuture<T> start()
|
| 50 |
+
{
|
| 51 |
+
return start(TaskStartParameters());
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
QFuture<T> start(const TaskStartParameters ¶meters)
|
| 55 |
+
{
|
| 56 |
+
promise.setThreadPool(parameters.threadPool);
|
| 57 |
+
promise.setRunnable(this);
|
| 58 |
+
promise.reportStarted();
|
| 59 |
+
QFuture<T> theFuture = promise.future();
|
| 60 |
+
|
| 61 |
+
if (parameters.threadPool) {
|
| 62 |
+
parameters.threadPool->start(this, parameters.priority);
|
| 63 |
+
} else {
|
| 64 |
+
promise.reportCanceled();
|
| 65 |
+
promise.reportFinished();
|
| 66 |
+
delete this;
|
| 67 |
+
}
|
| 68 |
+
return theFuture;
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
// For backward compatibility
|
| 72 |
+
QFuture<T> start(QThreadPool *pool) { return start({pool, 0}); }
|
| 73 |
+
|
| 74 |
+
void run() override
|
| 75 |
+
{
|
| 76 |
+
if (promise.isCanceled()) {
|
| 77 |
+
promise.reportFinished();
|
| 78 |
+
return;
|
| 79 |
+
}
|
| 80 |
+
#ifndef QT_NO_EXCEPTIONS
|
| 81 |
+
try {
|
| 82 |
+
#endif
|
| 83 |
+
runFunctor();
|
| 84 |
+
#ifndef QT_NO_EXCEPTIONS
|
| 85 |
+
} catch (QException &e) {
|
| 86 |
+
promise.reportException(e);
|
| 87 |
+
} catch (...) {
|
| 88 |
+
promise.reportException(QUnhandledException(std::current_exception()));
|
| 89 |
+
}
|
| 90 |
+
#endif
|
| 91 |
+
promise.reportFinished();
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
protected:
|
| 95 |
+
virtual void runFunctor() = 0;
|
| 96 |
+
|
| 97 |
+
QFutureInterface<T> promise;
|
| 98 |
+
};
|
| 99 |
+
|
| 100 |
+
} //namespace QtConcurrent
|
| 101 |
+
|
| 102 |
+
#endif //Q_QDOC
|
| 103 |
+
|
| 104 |
+
QT_END_NAMESPACE
|
| 105 |
+
|
| 106 |
+
#endif // QT_NO_CONCURRENT
|
| 107 |
+
|
| 108 |
+
#endif
|
qt/6.8.1/msvc2022_64/include/QtConcurrent/qtconcurrentstoredfunctioncall.h
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright (C) 2016 The Qt Company Ltd.
|
| 2 |
+
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
| 3 |
+
|
| 4 |
+
#ifndef QTCONCURRENT_STOREDFUNCTIONCALL_H
|
| 5 |
+
#define QTCONCURRENT_STOREDFUNCTIONCALL_H
|
| 6 |
+
|
| 7 |
+
#include <QtConcurrent/qtconcurrent_global.h>
|
| 8 |
+
|
| 9 |
+
#ifndef QT_NO_CONCURRENT
|
| 10 |
+
#include <QtConcurrent/qtconcurrentrunbase.h>
|
| 11 |
+
#include <QtCore/qpromise.h>
|
| 12 |
+
|
| 13 |
+
#include <type_traits>
|
| 14 |
+
|
| 15 |
+
QT_BEGIN_NAMESPACE
|
| 16 |
+
|
| 17 |
+
#ifndef Q_QDOC
|
| 18 |
+
|
| 19 |
+
namespace QtConcurrent {
|
| 20 |
+
|
| 21 |
+
template<typename...>
|
| 22 |
+
struct NonMemberFunctionResolver;
|
| 23 |
+
|
| 24 |
+
template <class Function, class PromiseType, class... Args>
|
| 25 |
+
struct NonMemberFunctionResolver<Function, PromiseType, Args...>
|
| 26 |
+
{
|
| 27 |
+
using Type = std::tuple<std::decay_t<Function>, QPromise<PromiseType> &, std::decay_t<Args>...>;
|
| 28 |
+
static_assert(std::is_invocable_v<std::decay_t<Function>, QPromise<PromiseType> &, std::decay_t<Args>...>,
|
| 29 |
+
"It's not possible to invoke the function with passed arguments.");
|
| 30 |
+
static_assert(std::is_void_v<std::invoke_result_t<std::decay_t<Function>, QPromise<PromiseType> &, std::decay_t<Args>...>>,
|
| 31 |
+
"The function must return void type.");
|
| 32 |
+
|
| 33 |
+
static constexpr void invoke(std::decay_t<Function> function, QPromise<PromiseType> &promise,
|
| 34 |
+
std::decay_t<Args>... args)
|
| 35 |
+
{
|
| 36 |
+
std::invoke(function, promise, args...);
|
| 37 |
+
}
|
| 38 |
+
static Type initData(Function &&f, QPromise<PromiseType> &promise, Args &&...args)
|
| 39 |
+
{
|
| 40 |
+
return Type { std::forward<Function>(f), std::ref(promise), std::forward<Args>(args)... };
|
| 41 |
+
}
|
| 42 |
+
};
|
| 43 |
+
|
| 44 |
+
template<typename...>
|
| 45 |
+
struct MemberFunctionResolver;
|
| 46 |
+
|
| 47 |
+
template <typename Function, typename PromiseType, typename Arg, typename ... Args>
|
| 48 |
+
struct MemberFunctionResolver<Function, PromiseType, Arg, Args...>
|
| 49 |
+
{
|
| 50 |
+
using Type = std::tuple<std::decay_t<Function>, std::decay_t<Arg>, QPromise<PromiseType> &, std::decay_t<Args>...>;
|
| 51 |
+
static_assert(std::is_invocable_v<std::decay_t<Function>, std::decay_t<Arg>, QPromise<PromiseType> &, std::decay_t<Args>...>,
|
| 52 |
+
"It's not possible to invoke the function with passed arguments.");
|
| 53 |
+
static_assert(std::is_void_v<std::invoke_result_t<std::decay_t<Function>, std::decay_t<Arg>, QPromise<PromiseType> &, std::decay_t<Args>...>>,
|
| 54 |
+
"The function must return void type.");
|
| 55 |
+
|
| 56 |
+
static constexpr void invoke(std::decay_t<Function> function, std::decay_t<Arg> object,
|
| 57 |
+
QPromise<PromiseType> &promise, std::decay_t<Args>... args)
|
| 58 |
+
{
|
| 59 |
+
std::invoke(function, object, promise, args...);
|
| 60 |
+
}
|
| 61 |
+
static Type initData(Function &&f, QPromise<PromiseType> &promise, Arg &&fa, Args &&...args)
|
| 62 |
+
{
|
| 63 |
+
return Type { std::forward<Function>(f), std::forward<Arg>(fa), std::ref(promise), std::forward<Args>(args)... };
|
| 64 |
+
}
|
| 65 |
+
};
|
| 66 |
+
|
| 67 |
+
template <class IsMember, class Function, class PromiseType, class... Args>
|
| 68 |
+
struct FunctionResolverHelper;
|
| 69 |
+
|
| 70 |
+
template <class Function, class PromiseType, class... Args>
|
| 71 |
+
struct FunctionResolverHelper<std::false_type, Function, PromiseType, Args...>
|
| 72 |
+
: public NonMemberFunctionResolver<Function, PromiseType, Args...>
|
| 73 |
+
{
|
| 74 |
+
};
|
| 75 |
+
|
| 76 |
+
template <class Function, class PromiseType, class... Args>
|
| 77 |
+
struct FunctionResolverHelper<std::true_type, Function, PromiseType, Args...>
|
| 78 |
+
: public MemberFunctionResolver<Function, PromiseType, Args...>
|
| 79 |
+
{
|
| 80 |
+
};
|
| 81 |
+
|
| 82 |
+
template <class Function, class PromiseType, class... Args>
|
| 83 |
+
struct FunctionResolver
|
| 84 |
+
: public FunctionResolverHelper<typename std::is_member_function_pointer<
|
| 85 |
+
std::decay_t<Function>>::type, Function, PromiseType, Args...>
|
| 86 |
+
{
|
| 87 |
+
};
|
| 88 |
+
|
| 89 |
+
template <class Function, class ...Args>
|
| 90 |
+
struct InvokeResult
|
| 91 |
+
{
|
| 92 |
+
static_assert(std::is_invocable_v<std::decay_t<Function>, std::decay_t<Args>...>,
|
| 93 |
+
"It's not possible to invoke the function with passed arguments.");
|
| 94 |
+
|
| 95 |
+
using Type = std::invoke_result_t<std::decay_t<Function>, std::decay_t<Args>...>;
|
| 96 |
+
};
|
| 97 |
+
|
| 98 |
+
template <class Function, class ...Args>
|
| 99 |
+
using InvokeResultType = typename InvokeResult<Function, Args...>::Type;
|
| 100 |
+
|
| 101 |
+
template <class ...Types>
|
| 102 |
+
using DecayedTuple = std::tuple<std::decay_t<Types>...>;
|
| 103 |
+
|
| 104 |
+
template <class Function, class ...Args>
|
| 105 |
+
struct StoredFunctionCall : public RunFunctionTaskBase<InvokeResultType<Function, Args...>>
|
| 106 |
+
{
|
| 107 |
+
StoredFunctionCall(DecayedTuple<Function, Args...> &&_data)
|
| 108 |
+
: data(std::move(_data))
|
| 109 |
+
{}
|
| 110 |
+
|
| 111 |
+
protected:
|
| 112 |
+
void runFunctor() override
|
| 113 |
+
{
|
| 114 |
+
constexpr auto invoke = [] (std::decay_t<Function> function,
|
| 115 |
+
std::decay_t<Args>... args) -> auto {
|
| 116 |
+
return std::invoke(function, args...);
|
| 117 |
+
};
|
| 118 |
+
|
| 119 |
+
if constexpr (std::is_void_v<InvokeResultType<Function, Args...>>) {
|
| 120 |
+
std::apply(invoke, std::move(data));
|
| 121 |
+
} else {
|
| 122 |
+
auto result = std::apply(invoke, std::move(data));
|
| 123 |
+
|
| 124 |
+
using T = InvokeResultType<Function, Args...>;
|
| 125 |
+
if constexpr (std::is_move_constructible_v<T>)
|
| 126 |
+
this->promise.reportAndMoveResult(std::move(result));
|
| 127 |
+
else if constexpr (std::is_copy_constructible_v<T>)
|
| 128 |
+
this->promise.reportResult(result);
|
| 129 |
+
}
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
private:
|
| 133 |
+
DecayedTuple<Function, Args...> data;
|
| 134 |
+
};
|
| 135 |
+
|
| 136 |
+
template <class Function, class PromiseType, class ...Args>
|
| 137 |
+
struct StoredFunctionCallWithPromise : public RunFunctionTaskBase<PromiseType>
|
| 138 |
+
{
|
| 139 |
+
using Resolver = FunctionResolver<Function, PromiseType, Args...>;
|
| 140 |
+
using DataType = typename Resolver::Type;
|
| 141 |
+
StoredFunctionCallWithPromise(Function &&f, Args &&...args)
|
| 142 |
+
: prom(this->promise),
|
| 143 |
+
data(std::move(Resolver::initData(std::forward<Function>(f), std::ref(prom),
|
| 144 |
+
std::forward<Args>(args)...)))
|
| 145 |
+
{}
|
| 146 |
+
|
| 147 |
+
StoredFunctionCallWithPromise(DecayedTuple<Function, Args...> &&_data)
|
| 148 |
+
: StoredFunctionCallWithPromise(std::move(_data),
|
| 149 |
+
std::index_sequence_for<std::decay_t<Function>, std::decay_t<Args>...>())
|
| 150 |
+
{}
|
| 151 |
+
|
| 152 |
+
protected:
|
| 153 |
+
void runFunctor() override
|
| 154 |
+
{
|
| 155 |
+
std::apply(Resolver::invoke, std::move(data));
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
private:
|
| 159 |
+
// helper to pack back the tuple into parameter pack
|
| 160 |
+
template<std::size_t... Is>
|
| 161 |
+
StoredFunctionCallWithPromise(DecayedTuple<Function, Args...> &&_data,
|
| 162 |
+
std::index_sequence<Is...>)
|
| 163 |
+
: StoredFunctionCallWithPromise(std::move(std::get<Is>(_data))...)
|
| 164 |
+
{}
|
| 165 |
+
|
| 166 |
+
QPromise<PromiseType> prom;
|
| 167 |
+
DataType data;
|
| 168 |
+
};
|
| 169 |
+
|
| 170 |
+
template<typename...>
|
| 171 |
+
struct NonPromiseTaskResolver;
|
| 172 |
+
|
| 173 |
+
template <typename Function, typename ... Args>
|
| 174 |
+
struct NonPromiseTaskResolver<Function, Args...>
|
| 175 |
+
{
|
| 176 |
+
using TaskWithArgs = DecayedTuple<Function, Args...>;
|
| 177 |
+
static auto run(TaskWithArgs &&args, const TaskStartParameters &startParameters) {
|
| 178 |
+
return (new StoredFunctionCall<Function, Args...>(std::move(args)))
|
| 179 |
+
->start(startParameters);
|
| 180 |
+
}
|
| 181 |
+
};
|
| 182 |
+
|
| 183 |
+
template<typename...>
|
| 184 |
+
struct PromiseTaskResolver;
|
| 185 |
+
|
| 186 |
+
template <typename Function, typename ... Args>
|
| 187 |
+
struct PromiseTaskResolver<Function, Args...>
|
| 188 |
+
{
|
| 189 |
+
static_assert(QtPrivate::ArgResolver<Function>::IsPromise::value,
|
| 190 |
+
"The first argument of passed callable object isn't a QPromise<T> & type. "
|
| 191 |
+
"Did you intend to pass a callable which takes a QPromise<T> & type as a first argument? "
|
| 192 |
+
"Otherwise it's not possible to invoke the function with passed arguments.");
|
| 193 |
+
using TaskWithArgs = DecayedTuple<Function, Args...>;
|
| 194 |
+
static auto run(TaskWithArgs &&args, const TaskStartParameters &startParameters) {
|
| 195 |
+
using PromiseType = typename QtPrivate::ArgResolver<Function>::PromiseType;
|
| 196 |
+
return (new StoredFunctionCallWithPromise<Function, PromiseType, Args...>(std::move(args)))
|
| 197 |
+
->start(startParameters);
|
| 198 |
+
}
|
| 199 |
+
};
|
| 200 |
+
|
| 201 |
+
template <class IsDirectlyInvocable, class Function, class... Args>
|
| 202 |
+
struct TaskResolverHelper;
|
| 203 |
+
|
| 204 |
+
template <class Function, class... Args>
|
| 205 |
+
struct TaskResolverHelper<std::true_type, Function, Args...>
|
| 206 |
+
: public NonPromiseTaskResolver<Function, Args...>
|
| 207 |
+
{
|
| 208 |
+
};
|
| 209 |
+
|
| 210 |
+
template <class Function, class... Args>
|
| 211 |
+
struct TaskResolverHelper<std::false_type, Function, Args...>
|
| 212 |
+
: public PromiseTaskResolver<Function, Args...>
|
| 213 |
+
{
|
| 214 |
+
};
|
| 215 |
+
|
| 216 |
+
template <class Function, class... Args>
|
| 217 |
+
struct TaskResolver : public TaskResolverHelper<typename std::is_invocable<std::decay_t<Function>,
|
| 218 |
+
std::decay_t<Args>...>::type, Function, Args...>
|
| 219 |
+
{
|
| 220 |
+
};
|
| 221 |
+
|
| 222 |
+
} //namespace QtConcurrent
|
| 223 |
+
|
| 224 |
+
#endif // Q_QDOC
|
| 225 |
+
|
| 226 |
+
QT_END_NAMESPACE
|
| 227 |
+
|
| 228 |
+
#endif // QT_NO_CONCURRENT
|
| 229 |
+
|
| 230 |
+
#endif
|
qt/6.8.1/msvc2022_64/include/QtConcurrent/qtconcurrenttask.h
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright (C) 2020 The Qt Company Ltd.
|
| 2 |
+
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
| 3 |
+
|
| 4 |
+
#ifndef QTCONCURRENTTASK_H
|
| 5 |
+
#define QTCONCURRENTTASK_H
|
| 6 |
+
|
| 7 |
+
#if !defined(QT_NO_CONCURRENT)
|
| 8 |
+
|
| 9 |
+
#include <QtConcurrent/qtaskbuilder.h>
|
| 10 |
+
|
| 11 |
+
QT_BEGIN_NAMESPACE
|
| 12 |
+
|
| 13 |
+
#ifdef Q_QDOC
|
| 14 |
+
|
| 15 |
+
namespace QtConcurrent {
|
| 16 |
+
|
| 17 |
+
template <class Task>
|
| 18 |
+
[[nodiscard]]
|
| 19 |
+
QTaskBuilder<Task> task(Task &&task);
|
| 20 |
+
|
| 21 |
+
} // namespace QtConcurrent
|
| 22 |
+
|
| 23 |
+
#else
|
| 24 |
+
|
| 25 |
+
namespace QtConcurrent {
|
| 26 |
+
|
| 27 |
+
template <class Task>
|
| 28 |
+
[[nodiscard]]
|
| 29 |
+
constexpr auto task(Task &&t) { return QTaskBuilder(std::forward<Task>(t)); }
|
| 30 |
+
|
| 31 |
+
} // namespace QtConcurrent
|
| 32 |
+
|
| 33 |
+
#endif // Q_QDOC
|
| 34 |
+
|
| 35 |
+
QT_END_NAMESPACE
|
| 36 |
+
|
| 37 |
+
#endif // !defined(QT_NO_CONCURRENT)
|
| 38 |
+
|
| 39 |
+
#endif // QTCONCURRENTTASK_H
|
qt/6.8.1/msvc2022_64/include/QtConcurrent/qtconcurrentthreadengine.h
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright (C) 2016 The Qt Company Ltd.
|
| 2 |
+
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
| 3 |
+
|
| 4 |
+
#ifndef QTCONCURRENT_THREADENGINE_H
|
| 5 |
+
#define QTCONCURRENT_THREADENGINE_H
|
| 6 |
+
|
| 7 |
+
#include <QtConcurrent/qtconcurrent_global.h>
|
| 8 |
+
|
| 9 |
+
#if !defined(QT_NO_CONCURRENT) ||defined(Q_QDOC)
|
| 10 |
+
|
| 11 |
+
#include <QtCore/qthreadpool.h>
|
| 12 |
+
#include <QtCore/qfuture.h>
|
| 13 |
+
#include <QtCore/qdebug.h>
|
| 14 |
+
#include <QtCore/qexception.h>
|
| 15 |
+
#include <QtCore/qwaitcondition.h>
|
| 16 |
+
#include <QtCore/qatomic.h>
|
| 17 |
+
#include <QtCore/qsemaphore.h>
|
| 18 |
+
|
| 19 |
+
QT_BEGIN_NAMESPACE
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
namespace QtConcurrent {
|
| 23 |
+
|
| 24 |
+
// The ThreadEngineBarrier counts worker threads, and allows one
|
| 25 |
+
// thread to wait for all others to finish. Tested for its use in
|
| 26 |
+
// QtConcurrent, requires more testing for use as a general class.
|
| 27 |
+
class ThreadEngineBarrier
|
| 28 |
+
{
|
| 29 |
+
private:
|
| 30 |
+
// The thread count is maintained as an integer in the count atomic
|
| 31 |
+
// variable. The count can be either positive or negative - a negative
|
| 32 |
+
// count signals that a thread is waiting on the barrier.
|
| 33 |
+
|
| 34 |
+
QAtomicInt count;
|
| 35 |
+
QSemaphore semaphore;
|
| 36 |
+
public:
|
| 37 |
+
ThreadEngineBarrier();
|
| 38 |
+
void acquire();
|
| 39 |
+
int release();
|
| 40 |
+
void wait();
|
| 41 |
+
int currentCount();
|
| 42 |
+
bool releaseUnlessLast();
|
| 43 |
+
};
|
| 44 |
+
|
| 45 |
+
enum ThreadFunctionResult { ThrottleThread, ThreadFinished };
|
| 46 |
+
|
| 47 |
+
// The ThreadEngine controls the threads used in the computation.
|
| 48 |
+
// Can be run in three modes: single threaded, multi-threaded blocking
|
| 49 |
+
// and multi-threaded asynchronous.
|
| 50 |
+
// The code for the single threaded mode is
|
| 51 |
+
class Q_CONCURRENT_EXPORT ThreadEngineBase: public QRunnable
|
| 52 |
+
{
|
| 53 |
+
public:
|
| 54 |
+
// Public API:
|
| 55 |
+
ThreadEngineBase(QThreadPool *pool);
|
| 56 |
+
virtual ~ThreadEngineBase();
|
| 57 |
+
void startSingleThreaded();
|
| 58 |
+
void startThread();
|
| 59 |
+
bool isCanceled();
|
| 60 |
+
void waitForResume();
|
| 61 |
+
bool isProgressReportingEnabled();
|
| 62 |
+
void setProgressValue(int progress);
|
| 63 |
+
void setProgressRange(int minimum, int maximum);
|
| 64 |
+
void acquireBarrierSemaphore();
|
| 65 |
+
void reportIfSuspensionDone() const;
|
| 66 |
+
|
| 67 |
+
protected: // The user overrides these:
|
| 68 |
+
virtual void start() {}
|
| 69 |
+
virtual void finish() {}
|
| 70 |
+
virtual ThreadFunctionResult threadFunction() { return ThreadFinished; }
|
| 71 |
+
virtual bool shouldStartThread() { return !shouldThrottleThread(); }
|
| 72 |
+
virtual bool shouldThrottleThread()
|
| 73 |
+
{
|
| 74 |
+
return futureInterface ? (futureInterface->isSuspending() || futureInterface->isSuspended())
|
| 75 |
+
: false;
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
private:
|
| 79 |
+
bool startThreadInternal();
|
| 80 |
+
void startThreads();
|
| 81 |
+
void threadExit();
|
| 82 |
+
bool threadThrottleExit();
|
| 83 |
+
void run() override;
|
| 84 |
+
virtual void asynchronousFinish() = 0;
|
| 85 |
+
#ifndef QT_NO_EXCEPTIONS
|
| 86 |
+
void handleException(const QException &exception);
|
| 87 |
+
#endif
|
| 88 |
+
protected:
|
| 89 |
+
QFutureInterfaceBase *futureInterface;
|
| 90 |
+
QThreadPool *threadPool;
|
| 91 |
+
ThreadEngineBarrier barrier;
|
| 92 |
+
QtPrivate::ExceptionStore exceptionStore;
|
| 93 |
+
QBasicMutex mutex;
|
| 94 |
+
};
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
template <typename T>
|
| 98 |
+
class ThreadEngine : public ThreadEngineBase
|
| 99 |
+
{
|
| 100 |
+
public:
|
| 101 |
+
typedef T ResultType;
|
| 102 |
+
|
| 103 |
+
ThreadEngine(QThreadPool *pool) : ThreadEngineBase(pool) {}
|
| 104 |
+
|
| 105 |
+
virtual T *result() { return nullptr; }
|
| 106 |
+
|
| 107 |
+
QFutureInterface<T> *futureInterfaceTyped()
|
| 108 |
+
{
|
| 109 |
+
return static_cast<QFutureInterface<T> *>(futureInterface);
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
// Runs the user algorithm using a single thread.
|
| 113 |
+
T *startSingleThreaded()
|
| 114 |
+
{
|
| 115 |
+
ThreadEngineBase::startSingleThreaded();
|
| 116 |
+
return result();
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
// Runs the user algorithm using multiple threads.
|
| 120 |
+
// Does not block, returns a future.
|
| 121 |
+
QFuture<T> startAsynchronously()
|
| 122 |
+
{
|
| 123 |
+
futureInterface = new QFutureInterface<T>();
|
| 124 |
+
|
| 125 |
+
// reportStart() must be called before starting threads, otherwise the
|
| 126 |
+
// user algorithm might finish while reportStart() is running, which
|
| 127 |
+
// is very bad.
|
| 128 |
+
futureInterface->reportStarted();
|
| 129 |
+
QFuture<T> future = QFuture<T>(futureInterfaceTyped());
|
| 130 |
+
start();
|
| 131 |
+
|
| 132 |
+
acquireBarrierSemaphore();
|
| 133 |
+
threadPool->start(this);
|
| 134 |
+
return future;
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
void asynchronousFinish() override
|
| 138 |
+
{
|
| 139 |
+
finish();
|
| 140 |
+
futureInterfaceTyped()->reportFinished(result());
|
| 141 |
+
delete futureInterfaceTyped();
|
| 142 |
+
delete this;
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
|
| 146 |
+
void reportResult(const T *_result, int index = -1)
|
| 147 |
+
{
|
| 148 |
+
if (futureInterface)
|
| 149 |
+
futureInterfaceTyped()->reportResult(_result, index);
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
void reportResults(const QList<T> &_result, int index = -1, int count = -1)
|
| 153 |
+
{
|
| 154 |
+
if (futureInterface)
|
| 155 |
+
futureInterfaceTyped()->reportResults(_result, index, count);
|
| 156 |
+
}
|
| 157 |
+
};
|
| 158 |
+
|
| 159 |
+
// The ThreadEngineStarter class ecapsulates the return type
|
| 160 |
+
// from the thread engine.
|
| 161 |
+
// Depending on how the it is used, it will run
|
| 162 |
+
// the engine in either blocking mode or asynchronous mode.
|
| 163 |
+
template <typename T>
|
| 164 |
+
class ThreadEngineStarterBase
|
| 165 |
+
{
|
| 166 |
+
public:
|
| 167 |
+
ThreadEngineStarterBase(ThreadEngine<T> *_threadEngine)
|
| 168 |
+
: threadEngine(_threadEngine) { }
|
| 169 |
+
|
| 170 |
+
inline ThreadEngineStarterBase(const ThreadEngineStarterBase &other)
|
| 171 |
+
: threadEngine(other.threadEngine) { }
|
| 172 |
+
|
| 173 |
+
QFuture<T> startAsynchronously()
|
| 174 |
+
{
|
| 175 |
+
return threadEngine->startAsynchronously();
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
operator QFuture<T>()
|
| 179 |
+
{
|
| 180 |
+
return startAsynchronously();
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
protected:
|
| 184 |
+
ThreadEngine<T> *threadEngine;
|
| 185 |
+
};
|
| 186 |
+
|
| 187 |
+
|
| 188 |
+
// We need to factor out the code that dereferences the T pointer,
|
| 189 |
+
// with a specialization where T is void. (code that dereferences a void *
|
| 190 |
+
// won't compile)
|
| 191 |
+
template <typename T>
|
| 192 |
+
class ThreadEngineStarter : public ThreadEngineStarterBase<T>
|
| 193 |
+
{
|
| 194 |
+
typedef ThreadEngineStarterBase<T> Base;
|
| 195 |
+
typedef ThreadEngine<T> TypedThreadEngine;
|
| 196 |
+
public:
|
| 197 |
+
ThreadEngineStarter(TypedThreadEngine *eng)
|
| 198 |
+
: Base(eng) { }
|
| 199 |
+
};
|
| 200 |
+
|
| 201 |
+
// Full template specialization where T is void.
|
| 202 |
+
template <>
|
| 203 |
+
class ThreadEngineStarter<void> : public ThreadEngineStarterBase<void>
|
| 204 |
+
{
|
| 205 |
+
public:
|
| 206 |
+
ThreadEngineStarter(ThreadEngine<void> *_threadEngine)
|
| 207 |
+
: ThreadEngineStarterBase<void>(_threadEngine) {}
|
| 208 |
+
};
|
| 209 |
+
|
| 210 |
+
//! [qtconcurrentthreadengine-1]
|
| 211 |
+
template <typename ThreadEngine>
|
| 212 |
+
inline ThreadEngineStarter<typename ThreadEngine::ResultType> startThreadEngine(ThreadEngine *threadEngine)
|
| 213 |
+
{
|
| 214 |
+
return ThreadEngineStarter<typename ThreadEngine::ResultType>(threadEngine);
|
| 215 |
+
}
|
| 216 |
+
|
| 217 |
+
} // namespace QtConcurrent
|
| 218 |
+
|
| 219 |
+
|
| 220 |
+
QT_END_NAMESPACE
|
| 221 |
+
|
| 222 |
+
#endif // QT_NO_CONCURRENT
|
| 223 |
+
|
| 224 |
+
#endif
|
qt/6.8.1/msvc2022_64/include/QtConcurrent/qtconcurrentversion.h
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file was generated by syncqt. */
|
| 2 |
+
#ifndef QT_QTCONCURRENT_VERSION_H
|
| 3 |
+
#define QT_QTCONCURRENT_VERSION_H
|
| 4 |
+
|
| 5 |
+
#define QTCONCURRENT_VERSION_STR "6.8.1"
|
| 6 |
+
|
| 7 |
+
#define QTCONCURRENT_VERSION 0x060801
|
| 8 |
+
|
| 9 |
+
#endif // QT_QTCONCURRENT_VERSION_H
|
qt/6.8.1/msvc2022_64/include/QtCore/QAbstractAnimation
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
#include "qabstractanimation.h" // IWYU pragma: export
|
qt/6.8.1/msvc2022_64/include/QtCore/QAbstractEventDispatcher
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
#include "qabstracteventdispatcher.h" // IWYU pragma: export
|
qt/6.8.1/msvc2022_64/include/QtCore/QAbstractEventDispatcherV2
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
#include "qabstracteventdispatcher.h" // IWYU pragma: export
|
qt/6.8.1/msvc2022_64/include/QtCore/QAbstractItemModel
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
#include "qabstractitemmodel.h" // IWYU pragma: export
|
qt/6.8.1/msvc2022_64/include/QtCore/QAbstractListModel
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
#include "qabstractitemmodel.h" // IWYU pragma: export
|
qt/6.8.1/msvc2022_64/include/QtCore/QAbstractNativeEventFilter
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
#include "qabstractnativeeventfilter.h" // IWYU pragma: export
|
qt/6.8.1/msvc2022_64/include/QtCore/QAbstractProxyModel
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
#include "qabstractproxymodel.h" // IWYU pragma: export
|
qt/6.8.1/msvc2022_64/include/QtCore/QAbstractTableModel
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
#include "qabstractitemmodel.h" // IWYU pragma: export
|
qt/6.8.1/msvc2022_64/include/QtCore/QAnimationDriver
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
#include "qabstractanimation.h" // IWYU pragma: export
|
qt/6.8.1/msvc2022_64/include/QtCore/QAnimationGroup
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
#include "qanimationgroup.h" // IWYU pragma: export
|
qt/6.8.1/msvc2022_64/include/QtCore/QAnyStringView
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
#include "qanystringview.h" // IWYU pragma: export
|
qt/6.8.1/msvc2022_64/include/QtCore/QApplicationStatic
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
#include "qapplicationstatic.h" // IWYU pragma: export
|
qt/6.8.1/msvc2022_64/include/QtCore/QArgument
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
#include "qobjectdefs.h" // IWYU pragma: export
|
qt/6.8.1/msvc2022_64/include/QtCore/QArrayData
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
#include "qarraydata.h" // IWYU pragma: export
|
qt/6.8.1/msvc2022_64/include/QtCore/QArrayDataOps
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
#include "qarraydataops.h" // IWYU pragma: export
|
qt/6.8.1/msvc2022_64/include/QtCore/q20algorithm.h
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright (C) 2021 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz <marc.mutz@kdab.com>
|
| 2 |
+
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
| 3 |
+
#ifndef Q20ALGORITHM_H
|
| 4 |
+
#define Q20ALGORITHM_H
|
| 5 |
+
|
| 6 |
+
#include <QtCore/qglobal.h>
|
| 7 |
+
|
| 8 |
+
#include <algorithm>
|
| 9 |
+
#include <QtCore/q20functional.h>
|
| 10 |
+
|
| 11 |
+
//
|
| 12 |
+
// W A R N I N G
|
| 13 |
+
// -------------
|
| 14 |
+
//
|
| 15 |
+
// This file is not part of the Qt API. Types and functions defined in this
|
| 16 |
+
// file can reliably be replaced by their std counterparts, once available.
|
| 17 |
+
// You may use these definitions in your own code, but be aware that we
|
| 18 |
+
// will remove them once Qt depends on the C++ version that supports
|
| 19 |
+
// them in namespace std. There will be NO deprecation warning, the
|
| 20 |
+
// definitions will JUST go away.
|
| 21 |
+
//
|
| 22 |
+
// If you can't agree to these terms, don't use these definitions!
|
| 23 |
+
//
|
| 24 |
+
// We mean it.
|
| 25 |
+
//
|
| 26 |
+
|
| 27 |
+
QT_BEGIN_NAMESPACE
|
| 28 |
+
|
| 29 |
+
namespace q20 {
|
| 30 |
+
// like std::<algorithm> (ie. not ranged, but constexpr)
|
| 31 |
+
#ifdef __cpp_lib_constexpr_algorithms
|
| 32 |
+
using std::copy;
|
| 33 |
+
using std::copy_if;
|
| 34 |
+
using std::copy_n;
|
| 35 |
+
using std::fill;
|
| 36 |
+
using std::fill_n;
|
| 37 |
+
using std::is_sorted_until;
|
| 38 |
+
using std::is_sorted;
|
| 39 |
+
using std::transform;
|
| 40 |
+
#else
|
| 41 |
+
template <typename InputIterator, typename OutputIterator>
|
| 42 |
+
constexpr OutputIterator
|
| 43 |
+
copy(InputIterator first, InputIterator last, OutputIterator dest)
|
| 44 |
+
{
|
| 45 |
+
while (first != last) {
|
| 46 |
+
*dest = *first;
|
| 47 |
+
++first;
|
| 48 |
+
++dest;
|
| 49 |
+
}
|
| 50 |
+
return dest;
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
template <typename InputIterator, typename OutputIterator, typename UnaryPredicate>
|
| 54 |
+
constexpr OutputIterator
|
| 55 |
+
copy_if(InputIterator first, InputIterator last, OutputIterator dest, UnaryPredicate pred)
|
| 56 |
+
{
|
| 57 |
+
while (first != last) {
|
| 58 |
+
if (pred(*first)) {
|
| 59 |
+
*dest = *first;
|
| 60 |
+
++dest;
|
| 61 |
+
}
|
| 62 |
+
++first;
|
| 63 |
+
}
|
| 64 |
+
return dest;
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
template <typename InputIterator, typename Size, typename OutputIterator>
|
| 68 |
+
constexpr OutputIterator
|
| 69 |
+
copy_n(InputIterator first, Size n, OutputIterator dest)
|
| 70 |
+
{
|
| 71 |
+
while (n > Size{0}) {
|
| 72 |
+
*dest = *first;
|
| 73 |
+
++first;
|
| 74 |
+
++dest;
|
| 75 |
+
--n;
|
| 76 |
+
}
|
| 77 |
+
return dest;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
template <typename ForwardIterator, typename Value>
|
| 81 |
+
constexpr void
|
| 82 |
+
fill(ForwardIterator first, ForwardIterator last, const Value &value)
|
| 83 |
+
{
|
| 84 |
+
while (first != last) {
|
| 85 |
+
*first = value;
|
| 86 |
+
++first;
|
| 87 |
+
}
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
template <typename OutputIterator, typename Size, typename Value>
|
| 91 |
+
constexpr OutputIterator
|
| 92 |
+
fill_n(OutputIterator first, Size n, const Value &value)
|
| 93 |
+
{
|
| 94 |
+
while (n > Size{0}) {
|
| 95 |
+
*first = value;
|
| 96 |
+
++first;
|
| 97 |
+
--n;
|
| 98 |
+
}
|
| 99 |
+
return first;
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
template <typename ForwardIterator, typename BinaryPredicate = std::less<>>
|
| 103 |
+
constexpr ForwardIterator
|
| 104 |
+
is_sorted_until(ForwardIterator first, ForwardIterator last, BinaryPredicate p = {})
|
| 105 |
+
{
|
| 106 |
+
if (first == last)
|
| 107 |
+
return first;
|
| 108 |
+
auto prev = first;
|
| 109 |
+
while (++first != last) {
|
| 110 |
+
if (p(*first, *prev))
|
| 111 |
+
return first;
|
| 112 |
+
prev = first;
|
| 113 |
+
}
|
| 114 |
+
return first;
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
template <typename ForwardIterator, typename BinaryPredicate = std::less<>>
|
| 118 |
+
constexpr bool is_sorted(ForwardIterator first, ForwardIterator last, BinaryPredicate p = {})
|
| 119 |
+
{
|
| 120 |
+
return q20::is_sorted_until(first, last, p) == last;
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
template <typename InputIterator, typename OutputIterator, typename UnaryFunction>
|
| 124 |
+
constexpr OutputIterator
|
| 125 |
+
transform(InputIterator first, InputIterator last, OutputIterator dest, UnaryFunction op)
|
| 126 |
+
{
|
| 127 |
+
while (first != last) {
|
| 128 |
+
*dest = op(*first);
|
| 129 |
+
++first;
|
| 130 |
+
++dest;
|
| 131 |
+
}
|
| 132 |
+
return dest;
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
// binary transform missing on purpose (no users)
|
| 136 |
+
|
| 137 |
+
#endif
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
namespace q20::ranges {
|
| 141 |
+
// like std::ranges::{any,all,none}_of, just unconstrained, so no range-overload
|
| 142 |
+
#ifdef __cpp_lib_ranges
|
| 143 |
+
using std::ranges::any_of;
|
| 144 |
+
using std::ranges::all_of;
|
| 145 |
+
using std::ranges::none_of;
|
| 146 |
+
#else
|
| 147 |
+
[[maybe_unused]] inline constexpr struct { // Niebloid
|
| 148 |
+
template <typename InputIterator, typename Sentinel,
|
| 149 |
+
typename Predicate, typename Projection = q20::identity>
|
| 150 |
+
[[maybe_unused]] constexpr bool operator()(InputIterator first, Sentinel last, Predicate pred, Projection proj = {}) const
|
| 151 |
+
{
|
| 152 |
+
while (first != last) {
|
| 153 |
+
if (std::invoke(pred, std::invoke(proj, *first)))
|
| 154 |
+
return true;
|
| 155 |
+
++first;
|
| 156 |
+
}
|
| 157 |
+
return false;
|
| 158 |
+
}
|
| 159 |
+
} any_of;
|
| 160 |
+
[[maybe_unused]] inline constexpr struct { // Niebloid
|
| 161 |
+
template <typename InputIterator, typename Sentinel,
|
| 162 |
+
typename Predicate, typename Projection = q20::identity>
|
| 163 |
+
[[maybe_unused]] constexpr bool operator()(InputIterator first, Sentinel last, Predicate pred, Projection proj = {}) const
|
| 164 |
+
{
|
| 165 |
+
while (first != last) {
|
| 166 |
+
if (!std::invoke(pred, std::invoke(proj, *first)))
|
| 167 |
+
return false;
|
| 168 |
+
++first;
|
| 169 |
+
}
|
| 170 |
+
return true;
|
| 171 |
+
}
|
| 172 |
+
} all_of;
|
| 173 |
+
[[maybe_unused]] inline constexpr struct { // Niebloid
|
| 174 |
+
template <typename InputIterator, typename Sentinel,
|
| 175 |
+
typename Predicate, typename Projection = q20::identity>
|
| 176 |
+
[[maybe_unused]] constexpr bool operator()(InputIterator first, Sentinel last, Predicate pred, Projection proj = {}) const
|
| 177 |
+
{
|
| 178 |
+
while (first != last) {
|
| 179 |
+
if (std::invoke(pred, std::invoke(proj, *first)))
|
| 180 |
+
return false;
|
| 181 |
+
++first;
|
| 182 |
+
}
|
| 183 |
+
return true;
|
| 184 |
+
}
|
| 185 |
+
} none_of;
|
| 186 |
+
#endif // __cpp_lib_ranges
|
| 187 |
+
} // namespace q20::ranges
|
| 188 |
+
|
| 189 |
+
QT_END_NAMESPACE
|
| 190 |
+
|
| 191 |
+
#endif /* Q20ALGORITHM_H */
|
qt/6.8.1/msvc2022_64/include/QtCore/q20chrono.h
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright (C) 2023 Ahmad Samir <a.samirh78@gmail.com>
|
| 2 |
+
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
| 3 |
+
|
| 4 |
+
#ifndef Q20CHRONO_H
|
| 5 |
+
#define Q20CHRONO_H
|
| 6 |
+
|
| 7 |
+
#include <QtCore/qtconfigmacros.h>
|
| 8 |
+
|
| 9 |
+
#include <chrono>
|
| 10 |
+
|
| 11 |
+
//
|
| 12 |
+
// W A R N I N G
|
| 13 |
+
// -------------
|
| 14 |
+
//
|
| 15 |
+
// This file is not part of the Qt API. Types and functions defined in this
|
| 16 |
+
// file can reliably be replaced by their std counterparts, once available.
|
| 17 |
+
// You may use these definitions in your own code, but be aware that we
|
| 18 |
+
// will remove them once Qt depends on the C++ version that supports
|
| 19 |
+
// them in namespace std. There will be NO deprecation warning, the
|
| 20 |
+
// definitions will JUST go away.
|
| 21 |
+
//
|
| 22 |
+
// If you can't agree to these terms, don't use these definitions!
|
| 23 |
+
//
|
| 24 |
+
// We mean it.
|
| 25 |
+
//
|
| 26 |
+
|
| 27 |
+
QT_BEGIN_NAMESPACE
|
| 28 |
+
|
| 29 |
+
namespace q20 {
|
| 30 |
+
namespace chrono {
|
| 31 |
+
|
| 32 |
+
#if defined(__GLIBCXX__)
|
| 33 |
+
// https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libstdc%2B%2B-v3/include/bits/chrono.h
|
| 34 |
+
using IntRep = int64_t;
|
| 35 |
+
#else
|
| 36 |
+
// https://github.com/llvm/llvm-project/blob/main/libcxx/include/__chrono/duration.h
|
| 37 |
+
// https://github.com/microsoft/STL/blob/main/stl/inc/__msvc_chrono.hpp
|
| 38 |
+
using IntRep = int;
|
| 39 |
+
#endif
|
| 40 |
+
|
| 41 |
+
#if __cpp_lib_chrono >= 201907L
|
| 42 |
+
using std::chrono::days;
|
| 43 |
+
using std::chrono::weeks;
|
| 44 |
+
using std::chrono::years;
|
| 45 |
+
using std::chrono::months;
|
| 46 |
+
|
| 47 |
+
static_assert(std::is_same_v<days::rep, IntRep>);
|
| 48 |
+
static_assert(std::is_same_v<weeks::rep, IntRep>);
|
| 49 |
+
static_assert(std::is_same_v<years::rep, IntRep>);
|
| 50 |
+
static_assert(std::is_same_v<months::rep, IntRep>);
|
| 51 |
+
#else
|
| 52 |
+
using days = std::chrono::duration<IntRep, std::ratio<86400>>;
|
| 53 |
+
using weeks = std::chrono::duration<IntRep, std::ratio_multiply<std::ratio<7>, days::period>>;
|
| 54 |
+
using years = std::chrono::duration<IntRep, std::ratio_multiply<std::ratio<146097, 400>, days::period>>;
|
| 55 |
+
using months = std::chrono::duration<IntRep, std::ratio_divide<years::period, std::ratio<12>>>;
|
| 56 |
+
#endif // __cpp_lib_chrono >= 201907L
|
| 57 |
+
} // namespace chrono
|
| 58 |
+
} // namespace q20
|
| 59 |
+
|
| 60 |
+
QT_END_NAMESPACE
|
| 61 |
+
|
| 62 |
+
#endif /* Q20CHRONO_H */
|
qt/6.8.1/msvc2022_64/include/QtCore/q20functional.h
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright (C) 2021 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz <marc.mutz@kdab.com>
|
| 2 |
+
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
| 3 |
+
#ifndef Q20FUNCTIONAL_H
|
| 4 |
+
#define Q20FUNCTIONAL_H
|
| 5 |
+
|
| 6 |
+
#include <QtCore/qglobal.h>
|
| 7 |
+
|
| 8 |
+
#include <functional>
|
| 9 |
+
|
| 10 |
+
//
|
| 11 |
+
// W A R N I N G
|
| 12 |
+
// -------------
|
| 13 |
+
//
|
| 14 |
+
// This file is not part of the Qt API. Types and functions defined in this
|
| 15 |
+
// file can reliably be replaced by their std counterparts, once available.
|
| 16 |
+
// You may use these definitions in your own code, but be aware that we
|
| 17 |
+
// will remove them once Qt depends on the C++ version that supports
|
| 18 |
+
// them in namespace std. There will be NO deprecation warning, the
|
| 19 |
+
// definitions will JUST go away.
|
| 20 |
+
//
|
| 21 |
+
// If you can't agree to these terms, don't use these definitions!
|
| 22 |
+
//
|
| 23 |
+
// We mean it.
|
| 24 |
+
//
|
| 25 |
+
|
| 26 |
+
#include <functional>
|
| 27 |
+
|
| 28 |
+
QT_BEGIN_NAMESPACE
|
| 29 |
+
|
| 30 |
+
namespace q20 {
|
| 31 |
+
// like std::identity
|
| 32 |
+
#ifdef __cpp_lib_ranges
|
| 33 |
+
using std::identity;
|
| 34 |
+
#else
|
| 35 |
+
struct identity
|
| 36 |
+
{
|
| 37 |
+
struct is_transparent {};
|
| 38 |
+
template <typename T>
|
| 39 |
+
constexpr T &&operator()(T&& t) const noexcept { return std::forward<T>(t); }
|
| 40 |
+
};
|
| 41 |
+
#endif // __cpp_lib_ranges
|
| 42 |
+
} // namespace q20
|
| 43 |
+
|
| 44 |
+
QT_END_NAMESPACE
|
| 45 |
+
|
| 46 |
+
#endif /* Q20FUNCTIONAL_H */
|
qt/6.8.1/msvc2022_64/include/QtCore/q20iterator.h
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright (C) 2021 The Qt Company Ltd.
|
| 2 |
+
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
| 3 |
+
#ifndef Q20ITERATOR_H
|
| 4 |
+
#define Q20ITERATOR_H
|
| 5 |
+
|
| 6 |
+
#include <QtCore/qglobal.h>
|
| 7 |
+
|
| 8 |
+
#include <iterator>
|
| 9 |
+
|
| 10 |
+
//
|
| 11 |
+
// W A R N I N G
|
| 12 |
+
// -------------
|
| 13 |
+
//
|
| 14 |
+
// This file is not part of the Qt API. Types and functions defined in this
|
| 15 |
+
// file can reliably be replaced by their std counterparts, once available.
|
| 16 |
+
// You may use these definitions in your own code, but be aware that we
|
| 17 |
+
// will remove them once Qt depends on the C++ version that supports
|
| 18 |
+
// them in namespace std. There will be NO deprecation warning, the
|
| 19 |
+
// definitions will JUST go away.
|
| 20 |
+
//
|
| 21 |
+
// If you can't agree to these terms, don't use these definitions!
|
| 22 |
+
//
|
| 23 |
+
// We mean it.
|
| 24 |
+
//
|
| 25 |
+
|
| 26 |
+
QT_BEGIN_NAMESPACE
|
| 27 |
+
|
| 28 |
+
// like std::ssize
|
| 29 |
+
namespace q20 {
|
| 30 |
+
#ifdef __cpp_lib_ssize
|
| 31 |
+
using std::ssize;
|
| 32 |
+
#else
|
| 33 |
+
template<class C> constexpr auto ssize(const C &c)
|
| 34 |
+
-> std::common_type_t<std::ptrdiff_t, std::make_signed_t<decltype(c.size())>>
|
| 35 |
+
{ return static_cast<std::common_type_t<std::ptrdiff_t, std::make_signed_t<decltype(c.size())>>>(c.size()); }
|
| 36 |
+
|
| 37 |
+
template<class T, std::ptrdiff_t N> constexpr std::ptrdiff_t ssize(const T (&)[N]) noexcept
|
| 38 |
+
{ return N; }
|
| 39 |
+
#endif
|
| 40 |
+
} // namespace q20
|
| 41 |
+
|
| 42 |
+
// like q20::iter_reference_t
|
| 43 |
+
namespace q20 {
|
| 44 |
+
#ifdef __cpp_lib_ranges
|
| 45 |
+
using std::iter_reference_t;
|
| 46 |
+
#else
|
| 47 |
+
template <typename Dereferencable> // unconstrained (constraint requires concepts)
|
| 48 |
+
using iter_reference_t = decltype(*std::declval<Dereferencable&>());
|
| 49 |
+
#endif // __cpp_lib_ranges
|
| 50 |
+
} // namespace q20
|
| 51 |
+
|
| 52 |
+
QT_END_NAMESPACE
|
| 53 |
+
|
| 54 |
+
#endif /* Q20ITERATOR_H */
|
qt/6.8.1/msvc2022_64/include/QtCore/q20map.h
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright (C) 2023 Ahmad Samir <a.samirh78@gmail.com>
|
| 2 |
+
// Copyright (C) 2023 The Qt Company Ltd.
|
| 3 |
+
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
| 4 |
+
|
| 5 |
+
#ifndef Q20MAP_H
|
| 6 |
+
#define Q20MAP_H
|
| 7 |
+
|
| 8 |
+
#include <QtCore/qtconfigmacros.h>
|
| 9 |
+
|
| 10 |
+
#include <map>
|
| 11 |
+
#if __has_include(<memory_resource>)
|
| 12 |
+
# include <memory_resource>
|
| 13 |
+
#endif
|
| 14 |
+
|
| 15 |
+
//
|
| 16 |
+
// W A R N I N G
|
| 17 |
+
// -------------
|
| 18 |
+
//
|
| 19 |
+
// This file is not part of the Qt API. Types and functions defined in this
|
| 20 |
+
// file can reliably be replaced by their std counterparts, once available.
|
| 21 |
+
// You may use these definitions in your own code, but be aware that we
|
| 22 |
+
// will remove them once Qt depends on the C++ version that supports
|
| 23 |
+
// them in namespace std. There will be NO deprecation warning, the
|
| 24 |
+
// definitions will JUST go away.
|
| 25 |
+
//
|
| 26 |
+
// If you can't agree to these terms, don't use these definitions!
|
| 27 |
+
//
|
| 28 |
+
// We mean it.
|
| 29 |
+
//
|
| 30 |
+
|
| 31 |
+
QT_BEGIN_NAMESPACE
|
| 32 |
+
|
| 33 |
+
namespace q20 {
|
| 34 |
+
// like std::erase/std::erase_if for std::map
|
| 35 |
+
#if defined(__cpp_lib_erase_if) && __cpp_lib_erase_if >= 202002L // the one returning size_type
|
| 36 |
+
using std::erase_if;
|
| 37 |
+
#else
|
| 38 |
+
|
| 39 |
+
// Make it more specialized than the compiler's, so that our implementation is preferred over
|
| 40 |
+
// the compiler's (which may be present, but return void instead of the number of erased elements).
|
| 41 |
+
|
| 42 |
+
#define MAKE_OVERLOAD(map, allocator) \
|
| 43 |
+
template <typename Key, typename T, typename Compare, typename Pred> \
|
| 44 |
+
constexpr typename std::map<Key, T, Compare, std::allocator<std::pair<const Key, T>>>::size_type \
|
| 45 |
+
erase_if(std::map<Key, T, Compare, std::allocator<std::pair<const Key, T>>> &c, Pred p) \
|
| 46 |
+
{ \
|
| 47 |
+
const auto origSize = c.size(); \
|
| 48 |
+
for (auto it = c.begin(), end = c.end(); it != end; /* erasing */) { \
|
| 49 |
+
if (p(*it)) \
|
| 50 |
+
it = c.erase(it); \
|
| 51 |
+
else \
|
| 52 |
+
++it; \
|
| 53 |
+
} \
|
| 54 |
+
return origSize - c.size(); \
|
| 55 |
+
} \
|
| 56 |
+
/* end */
|
| 57 |
+
|
| 58 |
+
MAKE_OVERLOAD(map, allocator)
|
| 59 |
+
MAKE_OVERLOAD(multimap, allocator)
|
| 60 |
+
#ifdef __cpp_lib_polymorphic_allocator
|
| 61 |
+
MAKE_OVERLOAD(map, pmr::polymorphic_allocator)
|
| 62 |
+
MAKE_OVERLOAD(multimap, pmr::polymorphic_allocator)
|
| 63 |
+
#endif // __cpp_lib_polymorphic_allocator
|
| 64 |
+
|
| 65 |
+
#undef MAKE_OVERLOAD
|
| 66 |
+
|
| 67 |
+
#endif // __cpp_lib_erase_if
|
| 68 |
+
} // namespace q20
|
| 69 |
+
|
| 70 |
+
QT_END_NAMESPACE
|
| 71 |
+
|
| 72 |
+
#endif /* Q20MAP_H */
|
qt/6.8.1/msvc2022_64/include/QtCore/q20memory.h
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright (C) 2023 The Qt Company Ltd.
|
| 2 |
+
// Copyright (C) 2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz <marc.mutz@kdab.com>
|
| 3 |
+
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
| 4 |
+
|
| 5 |
+
#ifndef Q20MEMORY_H
|
| 6 |
+
#define Q20MEMORY_H
|
| 7 |
+
|
| 8 |
+
#include <QtCore/qtconfigmacros.h>
|
| 9 |
+
|
| 10 |
+
#include <memory>
|
| 11 |
+
|
| 12 |
+
#include <type_traits>
|
| 13 |
+
#include <utility>
|
| 14 |
+
|
| 15 |
+
//
|
| 16 |
+
// W A R N I N G
|
| 17 |
+
// -------------
|
| 18 |
+
//
|
| 19 |
+
// This file is not part of the Qt API. Types and functions defined in this
|
| 20 |
+
// file can reliably be replaced by their std counterparts, once available.
|
| 21 |
+
// You may use these definitions in your own code, but be aware that we
|
| 22 |
+
// will remove them once Qt depends on the C++ version that supports
|
| 23 |
+
// them in namespace std. There will be NO deprecation warning, the
|
| 24 |
+
// definitions will JUST go away.
|
| 25 |
+
//
|
| 26 |
+
// If you can't agree to these terms, don't use these definitions!
|
| 27 |
+
//
|
| 28 |
+
// We mean it.
|
| 29 |
+
//
|
| 30 |
+
|
| 31 |
+
QT_BEGIN_NAMESPACE
|
| 32 |
+
|
| 33 |
+
// like std::construct_at (but not whitelisted for constexpr)
|
| 34 |
+
namespace q20 {
|
| 35 |
+
#ifdef __cpp_lib_constexpr_dynamic_alloc
|
| 36 |
+
using std::construct_at;
|
| 37 |
+
#else
|
| 38 |
+
template <typename T,
|
| 39 |
+
typename... Args,
|
| 40 |
+
typename Enable = std::void_t<decltype(::new (std::declval<void *>()) T(std::declval<Args>()...))> >
|
| 41 |
+
T *construct_at(T *ptr, Args && ... args)
|
| 42 |
+
{
|
| 43 |
+
return ::new (const_cast<void *>(static_cast<const volatile void *>(ptr)))
|
| 44 |
+
T(std::forward<Args>(args)...);
|
| 45 |
+
}
|
| 46 |
+
#endif // __cpp_lib_constexpr_dynamic_alloc
|
| 47 |
+
} // namespace q20
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
namespace q20 {
|
| 51 |
+
// like std::to_address
|
| 52 |
+
#ifdef __cpp_lib_to_address
|
| 53 |
+
using std::to_address;
|
| 54 |
+
#else
|
| 55 |
+
// http://eel.is/c++draft/pointer.conversion
|
| 56 |
+
template <typename T>
|
| 57 |
+
constexpr T *to_address(T *p) noexcept {
|
| 58 |
+
// http://eel.is/c++draft/pointer.conversion#1:
|
| 59 |
+
// Mandates: T is not a function type.
|
| 60 |
+
static_assert(!std::is_function_v<T>, "to_address must not be used on function types");
|
| 61 |
+
return p;
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
template <typename Ptr, typename std::enable_if_t<!std::is_pointer_v<Ptr>, bool> = true>
|
| 65 |
+
constexpr auto to_address(const Ptr &ptr) noexcept; // fwd declared
|
| 66 |
+
|
| 67 |
+
namespace detail {
|
| 68 |
+
// http://eel.is/c++draft/pointer.conversion#3
|
| 69 |
+
template <typename Ptr, typename = void>
|
| 70 |
+
struct to_address_helper {
|
| 71 |
+
static auto get(const Ptr &ptr) noexcept
|
| 72 |
+
{ return q20::to_address(ptr.operator->()); }
|
| 73 |
+
};
|
| 74 |
+
template <typename Ptr>
|
| 75 |
+
struct to_address_helper<Ptr, std::void_t<
|
| 76 |
+
decltype(std::pointer_traits<Ptr>::to_address(std::declval<const Ptr&>()))
|
| 77 |
+
>>
|
| 78 |
+
{
|
| 79 |
+
static auto get(const Ptr &ptr) noexcept
|
| 80 |
+
{ return std::pointer_traits<Ptr>::to_address(ptr); }
|
| 81 |
+
};
|
| 82 |
+
} // namespace detail
|
| 83 |
+
|
| 84 |
+
template <typename Ptr, typename std::enable_if_t<!std::is_pointer_v<Ptr>, bool>>
|
| 85 |
+
constexpr auto to_address(const Ptr &ptr) noexcept
|
| 86 |
+
{ return detail::to_address_helper<Ptr>::get(ptr); }
|
| 87 |
+
|
| 88 |
+
#endif // __cpp_lib_to_address
|
| 89 |
+
} // namespace q20
|
| 90 |
+
|
| 91 |
+
QT_END_NAMESPACE
|
| 92 |
+
|
| 93 |
+
#endif /* Q20MEMORY_H */
|
qt/6.8.1/msvc2022_64/include/QtCore/q20type_traits.h
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright (C) 2021 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz <marc.mutz@kdab.com>
|
| 2 |
+
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
| 3 |
+
#ifndef Q20TYPE_TRAITS_H
|
| 4 |
+
#define Q20TYPE_TRAITS_H
|
| 5 |
+
|
| 6 |
+
#include <QtCore/qcompilerdetection.h>
|
| 7 |
+
#include <QtCore/qsystemdetection.h>
|
| 8 |
+
#include <QtCore/qtconfigmacros.h>
|
| 9 |
+
|
| 10 |
+
//
|
| 11 |
+
// W A R N I N G
|
| 12 |
+
// -------------
|
| 13 |
+
//
|
| 14 |
+
// This file is not part of the Qt API. Types and functions defined in this
|
| 15 |
+
// file can reliably be replaced by their std counterparts, once available.
|
| 16 |
+
// You may use these definitions in your own code, but be aware that we
|
| 17 |
+
// will remove them once Qt depends on the C++ version that supports
|
| 18 |
+
// them in namespace std. There will be NO deprecation warning, the
|
| 19 |
+
// definitions will JUST go away.
|
| 20 |
+
//
|
| 21 |
+
// If you can't agree to these terms, don't use these definitions!
|
| 22 |
+
//
|
| 23 |
+
// We mean it.
|
| 24 |
+
//
|
| 25 |
+
|
| 26 |
+
#include <type_traits>
|
| 27 |
+
|
| 28 |
+
QT_BEGIN_NAMESPACE
|
| 29 |
+
|
| 30 |
+
namespace q20 {
|
| 31 |
+
// like std::is_constant_evaluated
|
| 32 |
+
#ifdef __cpp_lib_is_constant_evaluated
|
| 33 |
+
using std::is_constant_evaluated;
|
| 34 |
+
#define QT_SUPPORTS_IS_CONSTANT_EVALUATED
|
| 35 |
+
#else
|
| 36 |
+
constexpr bool is_constant_evaluated() noexcept
|
| 37 |
+
{
|
| 38 |
+
#ifdef Q_OS_INTEGRITY
|
| 39 |
+
// Integrity complains "calling __has_builtin() from a constant expression".
|
| 40 |
+
// Avoid the __has_builtin check until we know what's going on.
|
| 41 |
+
return false;
|
| 42 |
+
#elif __has_builtin(__builtin_is_constant_evaluated) || \
|
| 43 |
+
(defined(Q_CC_MSVC_ONLY) /* >= 1925, but we require 1927 in qglobal.h */)
|
| 44 |
+
# define QT_SUPPORTS_IS_CONSTANT_EVALUATED
|
| 45 |
+
return __builtin_is_constant_evaluated();
|
| 46 |
+
#else
|
| 47 |
+
return false;
|
| 48 |
+
#endif
|
| 49 |
+
}
|
| 50 |
+
#endif // __cpp_lib_is_constant_evaluated
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
namespace q20 {
|
| 54 |
+
// like std::remove_cvref(_t)
|
| 55 |
+
#ifdef __cpp_lib_remove_cvref
|
| 56 |
+
using std::remove_cvref;
|
| 57 |
+
using std::remove_cvref_t;
|
| 58 |
+
#else
|
| 59 |
+
template <typename T>
|
| 60 |
+
using remove_cvref = std::remove_cv<std::remove_reference_t<T>>;
|
| 61 |
+
template <typename T>
|
| 62 |
+
using remove_cvref_t = std::remove_cv_t<std::remove_reference_t<T>>;
|
| 63 |
+
#endif // __cpp_lib_remove_cvref
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
namespace q20 {
|
| 67 |
+
// like std::type_identity(_t)
|
| 68 |
+
#ifdef __cpp_lib_type_identity
|
| 69 |
+
using std::type_identity;
|
| 70 |
+
using std::type_identity_t;
|
| 71 |
+
#else
|
| 72 |
+
template <typename T>
|
| 73 |
+
struct type_identity { using type = T; };
|
| 74 |
+
template <typename T>
|
| 75 |
+
using type_identity_t = typename type_identity<T>::type;
|
| 76 |
+
#endif // __cpp_lib_type_identity
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
QT_END_NAMESPACE
|
| 80 |
+
|
| 81 |
+
#endif /* Q20TYPE_TRAITS_H */
|
qt/6.8.1/msvc2022_64/include/QtCore/q20vector.h
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright (C) 2023 Ahmad Samir <a.samirh78@gmail.com>
|
| 2 |
+
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
| 3 |
+
|
| 4 |
+
#ifndef Q20VECTOR_H
|
| 5 |
+
#define Q20VECTOR_H
|
| 6 |
+
|
| 7 |
+
#include <QtCore/qtconfigmacros.h>
|
| 8 |
+
|
| 9 |
+
#include <algorithm>
|
| 10 |
+
#include <vector>
|
| 11 |
+
#if __has_include(<memory_resource>)
|
| 12 |
+
# include <memory_resource>
|
| 13 |
+
#endif
|
| 14 |
+
|
| 15 |
+
//
|
| 16 |
+
// W A R N I N G
|
| 17 |
+
// -------------
|
| 18 |
+
//
|
| 19 |
+
// This file is not part of the Qt API. Types and functions defined in this
|
| 20 |
+
// file can reliably be replaced by their std counterparts, once available.
|
| 21 |
+
// You may use these definitions in your own code, but be aware that we
|
| 22 |
+
// will remove them once Qt depends on the C++ version that supports
|
| 23 |
+
// them in namespace std. There will be NO deprecation warning, the
|
| 24 |
+
// definitions will JUST go away.
|
| 25 |
+
//
|
| 26 |
+
// If you can't agree to these terms, don't use these definitions!
|
| 27 |
+
//
|
| 28 |
+
// We mean it.
|
| 29 |
+
//
|
| 30 |
+
|
| 31 |
+
QT_BEGIN_NAMESPACE
|
| 32 |
+
|
| 33 |
+
namespace q20 {
|
| 34 |
+
// like std::erase/std::erase_if for std::vector
|
| 35 |
+
#if defined(__cpp_lib_erase_if) && __cpp_lib_erase_if >= 202002L // the one returning size_type
|
| 36 |
+
using std::erase;
|
| 37 |
+
using std::erase_if;
|
| 38 |
+
#else
|
| 39 |
+
|
| 40 |
+
// Make it more specialized than the compiler's, so that our implementation is preferred over
|
| 41 |
+
// the compiler's (which may be present, but return void instead of the number of erased elements).
|
| 42 |
+
|
| 43 |
+
template <typename T, typename U>
|
| 44 |
+
constexpr typename std::vector<T, std::allocator<T>>::size_type
|
| 45 |
+
erase(std::vector<T, std::allocator<T>> &c, const U &value)
|
| 46 |
+
{
|
| 47 |
+
const auto origSize = c.size();
|
| 48 |
+
auto it = std::remove(c.begin(), c.end(), value);
|
| 49 |
+
c.erase(it, c.end());
|
| 50 |
+
return origSize - c.size();
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
template <typename T, typename Pred>
|
| 54 |
+
constexpr typename std::vector<T, std::allocator<T>>::size_type
|
| 55 |
+
erase_if(std::vector<T, std::allocator<T>> &c, Pred pred)
|
| 56 |
+
{
|
| 57 |
+
const auto origSize = c.size();
|
| 58 |
+
auto it = std::remove_if(c.begin(), c.end(), pred);
|
| 59 |
+
c.erase(it, c.end());
|
| 60 |
+
return origSize - c.size();
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
#ifdef __cpp_lib_polymorphic_allocator
|
| 64 |
+
template <typename T, typename U>
|
| 65 |
+
constexpr typename std::vector<T, std::pmr::polymorphic_allocator<T>>::size_type
|
| 66 |
+
erase(std::vector<T, std::pmr::polymorphic_allocator<T>> &c, const U &value)
|
| 67 |
+
{
|
| 68 |
+
const auto origSize = c.size();
|
| 69 |
+
auto it = std::remove(c.begin(), c.end(), value);
|
| 70 |
+
c.erase(it, c.end());
|
| 71 |
+
return origSize - c.size();
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
template <typename T, typename Pred>
|
| 75 |
+
constexpr typename std::vector<T, std::pmr::polymorphic_allocator<T>>::size_type
|
| 76 |
+
erase_if(std::vector<T, std::pmr::polymorphic_allocator<T>> &c, Pred pred)
|
| 77 |
+
{
|
| 78 |
+
const auto origSize = c.size();
|
| 79 |
+
auto it = std::remove_if(c.begin(), c.end(), pred);
|
| 80 |
+
c.erase(it, c.end());
|
| 81 |
+
return origSize - c.size();
|
| 82 |
+
}
|
| 83 |
+
#endif // __cpp_lib_polymorphic_allocator
|
| 84 |
+
|
| 85 |
+
#endif // __cpp_lib_erase_if
|
| 86 |
+
} // namespace q20
|
| 87 |
+
|
| 88 |
+
QT_END_NAMESPACE
|
| 89 |
+
|
| 90 |
+
#endif /* Q20VECTOR_H */
|
qt/6.8.1/msvc2022_64/include/QtCore/q23functional.h
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright (C) 2022 The Qt Company Ltd.
|
| 2 |
+
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
| 3 |
+
#ifndef Q23FUNCTIONAL_H
|
| 4 |
+
#define Q23FUNCTIONAL_H
|
| 5 |
+
|
| 6 |
+
#include <QtCore/qglobal.h>
|
| 7 |
+
#include <QtCore/q20functional.h>
|
| 8 |
+
|
| 9 |
+
//
|
| 10 |
+
// W A R N I N G
|
| 11 |
+
// -------------
|
| 12 |
+
//
|
| 13 |
+
// This file is not part of the Qt API. Types and functions defined in this
|
| 14 |
+
// file can reliably be replaced by their std counterparts, once available.
|
| 15 |
+
// You may use these definitions in your own code, but be aware that we
|
| 16 |
+
// will remove them once Qt depends on the C++ version that supports
|
| 17 |
+
// them in namespace std. There will be NO deprecation warning, the
|
| 18 |
+
// definitions will JUST go away.
|
| 19 |
+
//
|
| 20 |
+
// If you can't agree to these terms, don't use these definitions!
|
| 21 |
+
//
|
| 22 |
+
// We mean it.
|
| 23 |
+
//
|
| 24 |
+
|
| 25 |
+
QT_BEGIN_NAMESPACE
|
| 26 |
+
|
| 27 |
+
namespace q23 {
|
| 28 |
+
// like std::invoke_r
|
| 29 |
+
#ifdef __cpp_lib_invoke_r
|
| 30 |
+
using std::invoke_r;
|
| 31 |
+
#else
|
| 32 |
+
template <typename R, typename F, typename...Args>
|
| 33 |
+
constexpr
|
| 34 |
+
std::enable_if_t<std::is_invocable_r_v<R, F, Args...>, R>
|
| 35 |
+
invoke_r(F&& f, Args&&... args)
|
| 36 |
+
noexcept(std::is_nothrow_invocable_r_v<R, F, Args...>)
|
| 37 |
+
{
|
| 38 |
+
// ### use q20::invoke for a constexpr std::invoke
|
| 39 |
+
if constexpr (std::is_void_v<R>)
|
| 40 |
+
std::invoke(std::forward<F>(f), std::forward<Args>(args)...);
|
| 41 |
+
else
|
| 42 |
+
return std::invoke(std::forward<F>(f), std::forward<Args>(args)...);
|
| 43 |
+
}
|
| 44 |
+
#endif // __cpp_lib_invoke_r
|
| 45 |
+
} // namespace q23
|
| 46 |
+
|
| 47 |
+
QT_END_NAMESPACE
|
| 48 |
+
|
| 49 |
+
#endif /* Q23FUNCTIONAL_H */
|
qt/6.8.1/msvc2022_64/include/QtCore/q23utility.h
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright (C) 2023 The Qt Company Ltd.
|
| 2 |
+
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
| 3 |
+
#ifndef Q23UTILITY_H
|
| 4 |
+
#define Q23UTILITY_H
|
| 5 |
+
|
| 6 |
+
#include <QtCore/qtconfigmacros.h>
|
| 7 |
+
|
| 8 |
+
#include <utility>
|
| 9 |
+
|
| 10 |
+
//
|
| 11 |
+
// W A R N I N G
|
| 12 |
+
// -------------
|
| 13 |
+
//
|
| 14 |
+
// This file is not part of the Qt API. Types and functions defined in this
|
| 15 |
+
// file can reliably be replaced by their std counterparts, once available.
|
| 16 |
+
// You may use these definitions in your own code, but be aware that we
|
| 17 |
+
// will remove them once Qt depends on the C++ version that supports
|
| 18 |
+
// them in namespace std. There will be NO deprecation warning, the
|
| 19 |
+
// definitions will JUST go away.
|
| 20 |
+
//
|
| 21 |
+
// If you can't agree to these terms, don't use these definitions!
|
| 22 |
+
//
|
| 23 |
+
// We mean it.
|
| 24 |
+
//
|
| 25 |
+
|
| 26 |
+
QT_BEGIN_NAMESPACE
|
| 27 |
+
|
| 28 |
+
namespace q23 {
|
| 29 |
+
// like std::forward_like
|
| 30 |
+
#ifdef __cpp_lib_forward_like
|
| 31 |
+
using std::forward_like;
|
| 32 |
+
#else
|
| 33 |
+
|
| 34 |
+
namespace _detail {
|
| 35 |
+
|
| 36 |
+
// [forward]/6.1 COPY_CONST
|
| 37 |
+
template <typename A, typename B>
|
| 38 |
+
using copy_const_t = std::conditional_t<
|
| 39 |
+
std::is_const_v<A>, const B,
|
| 40 |
+
/* else */ B
|
| 41 |
+
>;
|
| 42 |
+
|
| 43 |
+
// [forward]/6.2 OVERRIDE_REF
|
| 44 |
+
template <typename A, typename B>
|
| 45 |
+
using override_ref_t = std::conditional_t<
|
| 46 |
+
std::is_rvalue_reference_v<A>, std::remove_reference_t<B>&&,
|
| 47 |
+
/* else */ B&
|
| 48 |
+
>;
|
| 49 |
+
|
| 50 |
+
// [forward]/6.3 "V"
|
| 51 |
+
template <typename T, typename U>
|
| 52 |
+
using forward_like_ret_t = override_ref_t<
|
| 53 |
+
T&&,
|
| 54 |
+
copy_const_t<
|
| 55 |
+
std::remove_reference_t<T>,
|
| 56 |
+
std::remove_reference_t<U>
|
| 57 |
+
>
|
| 58 |
+
>;
|
| 59 |
+
|
| 60 |
+
} // namespace detail
|
| 61 |
+
|
| 62 |
+
// http://eel.is/c++draft/forward#lib:forward_like
|
| 63 |
+
template <class T, class U>
|
| 64 |
+
[[nodiscard]] constexpr auto forward_like(U &&x) noexcept
|
| 65 |
+
-> _detail::forward_like_ret_t<T, U>
|
| 66 |
+
{
|
| 67 |
+
using V = _detail::forward_like_ret_t<T, U>;
|
| 68 |
+
return static_cast<V>(x);
|
| 69 |
+
}
|
| 70 |
+
#endif // __cpp_lib_forward_like
|
| 71 |
+
} // namespace q23
|
| 72 |
+
|
| 73 |
+
QT_END_NAMESPACE
|
| 74 |
+
|
| 75 |
+
#endif /* Q23UTILITY_H */
|
qt/6.8.1/msvc2022_64/include/QtCore/q26numeric.h
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright (C) 2024 The Qt Company Ltd.
|
| 2 |
+
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
| 3 |
+
#ifndef Q26NUMERIC_H
|
| 4 |
+
#define Q26NUMERIC_H
|
| 5 |
+
|
| 6 |
+
#include <QtCore/qglobal.h>
|
| 7 |
+
|
| 8 |
+
//
|
| 9 |
+
// W A R N I N G
|
| 10 |
+
// -------------
|
| 11 |
+
//
|
| 12 |
+
// This file is not part of the Qt API. Types and functions defined in this
|
| 13 |
+
// file can reliably be replaced by their std counterparts, once available.
|
| 14 |
+
// You may use these definitions in your own code, but be aware that we
|
| 15 |
+
// will remove them once Qt depends on the C++ version that supports
|
| 16 |
+
// them in namespace std. There will be NO deprecation warning, the
|
| 17 |
+
// definitions will JUST go away.
|
| 18 |
+
//
|
| 19 |
+
// If you can't agree to these terms, don't use these definitions!
|
| 20 |
+
//
|
| 21 |
+
// We mean it.
|
| 22 |
+
//
|
| 23 |
+
|
| 24 |
+
#include <numeric>
|
| 25 |
+
#include <limits>
|
| 26 |
+
#include <type_traits>
|
| 27 |
+
|
| 28 |
+
QT_BEGIN_NAMESPACE
|
| 29 |
+
|
| 30 |
+
namespace q26 {
|
| 31 |
+
|
| 32 |
+
// Like std::saturate_cast
|
| 33 |
+
#ifdef __cpp_lib_saturation_arithmetic
|
| 34 |
+
using std::saturate_cast;
|
| 35 |
+
#else
|
| 36 |
+
template <typename To, typename From>
|
| 37 |
+
constexpr auto saturate_cast(From x)
|
| 38 |
+
{
|
| 39 |
+
static_assert(std::is_integral_v<To>);
|
| 40 |
+
static_assert(std::is_integral_v<From>);
|
| 41 |
+
|
| 42 |
+
[[maybe_unused]]
|
| 43 |
+
constexpr auto Lo = (std::numeric_limits<To>::min)();
|
| 44 |
+
constexpr auto Hi = (std::numeric_limits<To>::max)();
|
| 45 |
+
|
| 46 |
+
if constexpr (std::is_signed_v<From> == std::is_signed_v<To>) {
|
| 47 |
+
// same signedness, we can accept regular integer conversion rules
|
| 48 |
+
return x < Lo ? Lo :
|
| 49 |
+
x > Hi ? Hi :
|
| 50 |
+
/*else*/ To(x);
|
| 51 |
+
} else {
|
| 52 |
+
if constexpr (std::is_signed_v<From>) { // ie. !is_signed_v<To>
|
| 53 |
+
if (x < From{0})
|
| 54 |
+
return To{0};
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
// from here on, x >= 0
|
| 58 |
+
using FromU = std::make_unsigned_t<From>;
|
| 59 |
+
using ToU = std::make_unsigned_t<To>;
|
| 60 |
+
return FromU(x) > ToU(Hi) ? Hi : To(x); // assumes Hi >= 0
|
| 61 |
+
}
|
| 62 |
+
}
|
| 63 |
+
#endif // __cpp_lib_saturation_arithmetic
|
| 64 |
+
|
| 65 |
+
} // namespace q26
|
| 66 |
+
|
| 67 |
+
QT_END_NAMESPACE
|
| 68 |
+
|
| 69 |
+
#endif /* Q26NUMERIC_H */
|