4#ifndef QTCONCURRENT_STOREDFUNCTIONCALL_H
5#define QTCONCURRENT_STOREDFUNCTIONCALL_H
7#include <QtConcurrent/qtconcurrent_global.h>
9#ifndef QT_NO_CONCURRENT
10#include <QtConcurrent/qtconcurrentrunbase.h>
11#include <QtCore/qpromise.h>
24template <
class Function,
class PromiseType,
class... 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.");
34 std::decay_t<Args>...
args)
40 return Type { std::forward<Function>(
f), std::ref(promise), std::forward<Args>(
args)... };
47template <
typename Function,
typename PromiseType,
typename Arg,
typename ... 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.");
56 static constexpr void invoke(std::decay_t<Function> function, std::decay_t<Arg>
object,
63 return Type { std::forward<Function>(
f), std::forward<Arg>(fa), std::ref(promise), std::forward<Args>(
args)... };
67template <
class IsMember,
class Function,
class PromiseType,
class... Args>
70template <
class Function,
class PromiseType,
class... Args>
76template <
class Function,
class PromiseType,
class... Args>
82template <
class Function,
class PromiseType,
class... Args>
85 std::decay_t<Function>>::type, Function, PromiseType, Args...>
89template <
class Function,
class ...Args>
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.");
95 using Type = std::invoke_result_t<std::decay_t<Function>, std::decay_t<Args>...>;
98template <
class Function,
class ...Args>
101template <
class ...Types>
104template <
class Function,
class ...Args>
114 constexpr auto invoke = [] (std::decay_t<Function>
function,
115 std::decay_t<Args>...
args) ->
auto {
120 std::apply(invoke, std::move(
data));
122 auto result = std::apply(invoke, std::move(
data));
125 if constexpr (std::is_move_constructible_v<T>)
127 else if constexpr (std::is_copy_constructible_v<T>)
136template <
class Function,
class PromiseType,
class ...Args>
155 std::apply(Resolver::invoke, std::move(
data));
160 template<std::size_t... Is>
162 std::index_sequence<Is...>)
173template <
typename Function,
typename ... Args>
179 ->start(startParameters);
186template <
typename Function,
typename ... Args>
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.");
197 ->start(startParameters);
201template <
class IsDirectlyInvocable,
class Function,
class... Args>
204template <
class Function,
class... Args>
210template <
class Function,
class... Args>
216template <
class Function,
class... Args>
218 std::decay_t<Args>...>::type, Function, Args...>
bool reportResult(const T *result, int index=-1)
bool reportAndMoveResult(T &&result, int index=-1)
QFutureInterface< InvokeResultType< Function, Args... > > promise
Combined button and popup list for selecting options.
typename InvokeResult< Function, Args... >::Type InvokeResultType
std::tuple< std::decay_t< Types >... > DecayedTuple
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction function
static QDBusError::ErrorType get(const char *name)
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
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)
DecayedTuple< Function, Args... > TaskWithArgs
static auto run(TaskWithArgs &&args, const TaskStartParameters &startParameters)
DecayedTuple< Function, Args... > TaskWithArgs
static auto run(TaskWithArgs &&args, const TaskStartParameters &startParameters)
void runFunctor() override
StoredFunctionCallWithPromise(DecayedTuple< Function, Args... > &&_data)
typename Resolver::Type DataType
StoredFunctionCallWithPromise(Function &&f, Args &&...args)
StoredFunctionCall(DecayedTuple< Function, Args... > &&_data)
void runFunctor() override