5#ifndef QTCONCURRENT_STOREDFUNCTIONCALL_H
6#define QTCONCURRENT_STOREDFUNCTIONCALL_H
8#include <QtConcurrent/qtconcurrent_global.h>
10#ifndef QT_NO_CONCURRENT
11#include <QtConcurrent/qtconcurrentrunbase.h>
12#include <QtCore/qpromise.h>
25template <
class Function,
class PromiseType,
class... Args>
30 "It's not possible to invoke the function with passed arguments.");
32 "The function must return void type.");
34 static constexpr void invoke(std::decay_t<Function> function, QPromise<PromiseType> &promise,
35 std::decay_t<Args>... args)
37 std::invoke(function, promise, args...);
39 static Type initData(Function &&f, QPromise<PromiseType> &promise, Args &&...args)
41 return Type { std::forward<Function>(f), std::ref(promise), std::forward<Args>(args)... };
48template <
typename Function,
typename PromiseType,
typename Arg,
typename ... Args>
53 "It's not possible to invoke the function with passed arguments.");
55 "The function must return void type.");
57 static constexpr void invoke(std::decay_t<Function> function, std::decay_t<Arg> object,
58 QPromise<PromiseType> &promise, std::decay_t<Args>... args)
60 std::invoke(function, object, promise, args...);
62 static Type initData(Function &&f, QPromise<PromiseType> &promise, Arg &&fa, Args &&...args)
64 return Type { std::forward<Function>(f), std::forward<Arg>(fa), std::ref(promise), std::forward<Args>(args)... };
68template <
class IsMember,
class Function,
class PromiseType,
class... Args>
83template <
class Function,
class PromiseType,
class... Args>
90template <
class Function,
class ...Args>
94 "It's not possible to invoke the function with passed arguments.");
99template <
class Function,
class ...Args>
102template <
class ...
Types>
105template <
class Function,
class ...Args>
137template <
class Function,
class PromiseType,
class ...Args>
174template <
typename Function,
typename ... Args>
178 static auto run(TaskWithArgs &&args,
const TaskStartParameters &startParameters) {
179 return (
new StoredFunctionCall<Function, Args...>(std::move(args)))
180 ->start(startParameters);
187template <
typename Function,
typename ... Args>
191 "The first argument of passed callable object isn't a QPromise<T> & type. "
192 "Did you intend to pass a callable which takes a QPromise<T> & type as a first argument? "
193 "Otherwise it's not possible to invoke the function with passed arguments.");
195 static auto run(TaskWithArgs &&args,
const TaskStartParameters &startParameters) {
196 using PromiseType =
typename QtPrivate::ArgResolver<Function>::PromiseType;
197 return (
new StoredFunctionCallWithPromise<Function, PromiseType, Args...>(std::move(args)))
198 ->start(startParameters);
202template <
class IsDirectlyInvocable,
class Function,
class... Args>
217template <
class Function,
class... Args>
typename InvokeResult< Function, Args... >::Type InvokeResultType
static Type initData(Function &&f, QPromise< PromiseType > &promise, Arg &&fa, Args &&...args)
static constexpr void invoke(std::decay_t< Function > function, std::decay_t< Arg > object, QPromise< PromiseType > &promise, std::decay_t< Args >... args)
static constexpr void invoke(std::decay_t< Function > function, QPromise< PromiseType > &promise, std::decay_t< Args >... args)
static Type initData(Function &&f, QPromise< PromiseType > &promise, Args &&...args)
static auto run(TaskWithArgs &&args, const TaskStartParameters &startParameters)
static auto run(TaskWithArgs &&args, const TaskStartParameters &startParameters)
typename Resolver::Type DataType
FunctionResolver< Function, PromiseType, Args... > Resolver
StoredFunctionCallWithPromise(Function &&f, Args &&...args)
void runFunctor() override