summaryrefslogtreecommitdiffstats
path: root/src/concurrent
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@qt.io>2020-09-30 21:01:36 +0200
committerJarek Kobus <jaroslaw.kobus@qt.io>2020-10-26 13:59:47 +0100
commitc91327645b1a659a5b749264d7fb3447c9c43c3f (patch)
treedefb4b2d5fe55ffa76852958393b138ceaf02ca2 /src/concurrent
parent0807ede08c6fb37ed27f920875ae892a0b4f64c7 (diff)
QtConcurrent: Reuse ArgResolver from qfuture_impl.h
Task-number: QTBUG-83331 Change-Id: I572f68f6d3be4a50970d8d77d070f175be3ec785 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Diffstat (limited to 'src/concurrent')
-rw-r--r--src/concurrent/qtconcurrentrun.h104
1 files changed, 4 insertions, 100 deletions
diff --git a/src/concurrent/qtconcurrentrun.h b/src/concurrent/qtconcurrentrun.h
index 5804393e25..79322b925f 100644
--- a/src/concurrent/qtconcurrentrun.h
+++ b/src/concurrent/qtconcurrentrun.h
@@ -73,102 +73,6 @@ namespace QtConcurrent {
namespace QtConcurrent {
-// Note: It's a copy taken from qfuture_impl.h with some specialization added
-// TODO: Get rid of the code repetition and unify this for both purposes, see QTBUG-83331
-template<typename...>
-struct ArgsType;
-
-template<typename Arg, typename... Args>
-struct ArgsType<Arg, Args...>
-{
- using PromiseType = void;
- static const bool IsPromise = false;
-};
-
-// Note: this specialization was added
-template<typename Arg, typename... Args>
-struct ArgsType<QPromise<Arg> &, Args...>
-{
- using PromiseType = Arg;
- static const bool IsPromise = true;
-};
-
-template<>
-struct ArgsType<>
-{
- using PromiseType = void;
- static const bool IsPromise = false;
-};
-
-template<typename F>
-struct ArgResolver : ArgResolver<decltype(&std::decay_t<F>::operator())>
-{
-};
-
-// Note: this specialization was added, see callableObjectWithState() test in qtconcurrentrun
-template<typename F>
-struct ArgResolver<std::reference_wrapper<F>> : ArgResolver<decltype(&std::decay_t<F>::operator())>
-{
-};
-
-template<typename R, typename... Args>
-struct ArgResolver<R(Args...)> : public ArgsType<Args...>
-{
-};
-
-template<typename R, typename... Args>
-struct ArgResolver<R (*)(Args...)> : public ArgsType<Args...>
-{
-};
-
-// Note: this specialization was added, see light() test in qtconcurrentrun
-template<typename R, typename... Args>
-struct ArgResolver<R (*&)(Args...)> : public ArgsType<Args...>
-{
-};
-
-// Note: this specialization was added, see light() test in qtconcurrentrun
-template<typename R, typename... Args>
-struct ArgResolver<R (* const)(Args...)> : public ArgsType<Args...>
-{
-};
-
-template<typename R, typename... Args>
-struct ArgResolver<R (&)(Args...)> : public ArgsType<Args...>
-{
-};
-
-template<typename Class, typename R, typename... Args>
-struct ArgResolver<R (Class::*)(Args...)> : public ArgsType<Args...>
-{
-};
-
-template<typename Class, typename R, typename... Args>
-struct ArgResolver<R (Class::*)(Args...) noexcept> : public ArgsType<Args...>
-{
-};
-
-template<typename Class, typename R, typename... Args>
-struct ArgResolver<R (Class::*)(Args...) const> : public ArgsType<Args...>
-{
-};
-
-template<typename Class, typename R, typename... Args>
-struct ArgResolver<R (Class::*)(Args...) const noexcept> : public ArgsType<Args...>
-{
-};
-
-// Note: this specialization was added, see crefFunction() test in qtconcurrentrun
-template<typename Class, typename R, typename... Args>
-struct ArgResolver<R (Class::* const)(Args...) const> : public ArgsType<Args...>
-{
-};
-
-template<typename Class, typename R, typename... Args>
-struct ArgResolver<R (Class::* const)(Args...) const noexcept> : public ArgsType<Args...>
-{
-};
-
template <class Function, class ...Args>
[[nodiscard]]
auto run(QThreadPool *pool, Function &&f, Args &&...args)
@@ -196,8 +100,8 @@ template <class Function, class ...Args>
[[nodiscard]]
auto runWithPromise(QThreadPool *pool, Function &&f, Args &&...args)
{
- static_assert(ArgResolver<Function>::IsPromise, "The first argument of passed callable object isn't a QPromise<T> & type.");
- using PromiseType = typename ArgResolver<Function>::PromiseType;
+ static_assert(QtPrivate::ArgResolver<Function>::IsPromise, "The first argument of passed callable object isn't a QPromise<T> & type.");
+ using PromiseType = typename QtPrivate::ArgResolver<Function>::PromiseType;
return runWithPromise<PromiseType>(pool, std::forward<Function>(f), std::forward<Args>(args)...);
}
@@ -205,8 +109,8 @@ template <class Function, class ...Args>
[[nodiscard]]
auto runWithPromise(QThreadPool *pool, std::reference_wrapper<const Function> &&functionWrapper, Args &&...args)
{
- static_assert(ArgResolver<const Function>::IsPromise, "The first argument of passed callable object isn't a QPromise<T> & type.");
- using PromiseType = typename ArgResolver<const Function>::PromiseType;
+ static_assert(QtPrivate::ArgResolver<const Function>::IsPromise, "The first argument of passed callable object isn't a QPromise<T> & type.");
+ using PromiseType = typename QtPrivate::ArgResolver<const Function>::PromiseType;
return runWithPromise<PromiseType>(pool, std::forward<const Function>(functionWrapper.get()), std::forward<Args>(args)...);
}