From c977e74afd18afff8729070f631e6b7a3f2887f5 Mon Sep 17 00:00:00 2001 From: Vitaly Fanaskov Date: Wed, 26 Feb 2020 15:22:40 +0100 Subject: QtConcurrent::run: accept more then five function's arguments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [ChangeLog][Potentially Source-Incompatible Changes] QtConcurrent::run has the following signatures: run(Function &&f, Args &&...args) and run(QThreadPool *pool, Function &&f, Args &&...args). If f is a member pointer, the first argument of args should be an object for which that member is defined (or a reference, or a pointer to it). See the documentation for more details. Fixes: QTBUG-82383 Change-Id: I18f7fcfb2adbdd9f75b29c346bd3516304e32d31 Reviewed-by: MÃ¥rten Nordheim Reviewed-by: Sona Kurazyan --- examples/vulkan/hellovulkancubes/renderer.cpp | 4 +- .../code/src_concurrent_qtconcurrentrun.cpp | 36 +- src/concurrent/qtconcurrentrun.cpp | 8 + src/concurrent/qtconcurrentrun.h | 846 +------- src/concurrent/qtconcurrentstoredfunctioncall.h | 2206 +------------------- .../qtconcurrentrun/tst_qtconcurrentrun.cpp | 178 +- tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp | 14 +- tests/auto/corelib/io/qurl/tst_qurl.cpp | 2 +- .../mimetypes/qmimedatabase/tst_qmimedatabase.cpp | 16 +- 9 files changed, 198 insertions(+), 3112 deletions(-) diff --git a/examples/vulkan/hellovulkancubes/renderer.cpp b/examples/vulkan/hellovulkancubes/renderer.cpp index f104d79002..da493de739 100644 --- a/examples/vulkan/hellovulkancubes/renderer.cpp +++ b/examples/vulkan/hellovulkancubes/renderer.cpp @@ -136,7 +136,7 @@ void Renderer::initResources() if (!m_floorMaterial.fs.isValid()) m_floorMaterial.fs.load(inst, dev, QStringLiteral(":/color_frag.spv")); - m_pipelinesFuture = QtConcurrent::run(this, &Renderer::createPipelines); + m_pipelinesFuture = QtConcurrent::run(&Renderer::createPipelines, this); } void Renderer::createPipelines() @@ -879,7 +879,7 @@ void Renderer::startNextFrame() // finished. Q_ASSERT(!m_framePending); m_framePending = true; - QFuture future = QtConcurrent::run(this, &Renderer::buildFrame); + QFuture future = QtConcurrent::run(&Renderer::buildFrame, this); m_frameWatcher.setFuture(future); } diff --git a/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentrun.cpp b/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentrun.cpp index 5437822842..0b82766054 100644 --- a/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentrun.cpp +++ b/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentrun.cpp @@ -93,7 +93,7 @@ QString result = future.result(); //! [4] // call 'QList QByteArray::split(char sep) const' in a separate thread QByteArray bytearray = "hello world"; -QFuture > future = QtConcurrent::run(bytearray, &QByteArray::split, ','); +QFuture > future = QtConcurrent::run(&QByteArray::split, bytearray, ','); ... QList result = future.result(); //! [4] @@ -101,16 +101,46 @@ QList result = future.result(); //! [5] // call 'void QImage::invertPixels(InvertMode mode)' in a separate thread QImage image = ...; -QFuture future = QtConcurrent::run(&image, &QImage::invertPixels, QImage::InvertRgba); +QFuture future = QtConcurrent::run(&QImage::invertPixels, &image, QImage::InvertRgba); ... future.waitForFinished(); // At this point, the pixels in 'image' have been inverted //! [5] - //! [6] QFuture future = QtConcurrent::run([=]() { // Code in this block will run in another thread }); ... //! [6] + +//! [7] +static void addOne(int &n) { ++n; } +... +int n = 42; +QtConcurrent::run(&addOne, std::ref(n)).waitForFinished(); // n == 43 +//! [7] + +//! [8] +struct TestClass +{ + void operator()(int s1) { s = s1; } + int s = 42; +}; + +... + +TestClass o; + +// Modify original object +QtConcurrent::run(std::ref(o), 15).waitForFinished(); // o.s == 15 + +// Modify a copy of the original object +QtConcurrent::run(o, 42).waitForFinished(); // o.s == 15 + +// Use a temporary object +QtConcurrent::run(TestClass(), 42).waitForFinished(); + +// Ill-formed +QtConcurrent::run(&o, 42).waitForFinished(); // compilation error +//! [8] diff --git a/src/concurrent/qtconcurrentrun.cpp b/src/concurrent/qtconcurrentrun.cpp index d9867e1f1a..c5f2e113a2 100644 --- a/src/concurrent/qtconcurrentrun.cpp +++ b/src/concurrent/qtconcurrentrun.cpp @@ -112,6 +112,14 @@ Calling a lambda function is done like this: \snippet code/src_concurrent_qtconcurrentrun.cpp 6 + + Calling a function modifies an object passed by reference is done like this: + + \snippet code/src_concurrent_qtconcurrentrun.cpp 7 + + Using callable object is done like this: + + \snippet code/src_concurrent_qtconcurrentrun.cpp 8 */ /*! diff --git a/src/concurrent/qtconcurrentrun.h b/src/concurrent/qtconcurrentrun.h index 22dae70460..15a207be33 100644 --- a/src/concurrent/qtconcurrentrun.h +++ b/src/concurrent/qtconcurrentrun.h @@ -37,7 +37,6 @@ ** ****************************************************************************/ -// Generated code, do not edit! Use generator at tools/qtconcurrent/generaterun/ #ifndef QTCONCURRENT_RUN_H #define QTCONCURRENT_RUN_H @@ -68,847 +67,20 @@ namespace QtConcurrent { namespace QtConcurrent { -template -QFuture run(T (*functionPointer)()) +template +[[nodiscard]] +auto run(QThreadPool *pool, Function &&f, Args &&...args) { - return (new StoredFunctorCall0(functionPointer))->start(); -} -template -QFuture run(T (*functionPointer)(Param1), const Arg1 &arg1) -{ - return (new StoredFunctorCall1(functionPointer, arg1))->start(); -} -template -QFuture run(T (*functionPointer)(Param1, Param2), const Arg1 &arg1, const Arg2 &arg2) -{ - return (new StoredFunctorCall2(functionPointer, arg1, arg2))->start(); -} -template -QFuture run(T (*functionPointer)(Param1, Param2, Param3), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) -{ - return (new StoredFunctorCall3(functionPointer, arg1, arg2, arg3))->start(); -} -template -QFuture run(T (*functionPointer)(Param1, Param2, Param3, Param4), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) -{ - return (new StoredFunctorCall4(functionPointer, arg1, arg2, arg3, arg4))->start(); -} -template -QFuture run(T (*functionPointer)(Param1, Param2, Param3, Param4, Param5), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) -{ - return (new StoredFunctorCall5(functionPointer, arg1, arg2, arg3, arg4, arg5))->start(); -} - -template -auto run(Functor functor) -> typename std::enable_if::Value, QFuture>::type -{ - typedef decltype(functor()) result_type; - return (new StoredFunctorCall0(functor))->start(); -} - -template -auto run(Functor functor, const Arg1 &arg1) - -> typename std::enable_if::Value, QFuture>::type -{ - typedef decltype(functor(arg1)) result_type; - return (new StoredFunctorCall1(functor, arg1))->start(); -} - -template -auto run(Functor functor, const Arg1 &arg1, const Arg2 &arg2) - -> typename std::enable_if::Value, QFuture>::type -{ - typedef decltype(functor(arg1, arg2)) result_type; - return (new StoredFunctorCall2(functor, arg1, arg2))->start(); -} - -template -auto run(Functor functor, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) - -> typename std::enable_if::Value, QFuture>::type -{ - typedef decltype(functor(arg1, arg2, arg3)) result_type; - return (new StoredFunctorCall3(functor, arg1, arg2, arg3))->start(); -} - -template -auto run(Functor functor, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) - -> typename std::enable_if::Value, QFuture>::type -{ - typedef decltype(functor(arg1, arg2, arg3, arg4)) result_type; - return (new StoredFunctorCall4(functor, arg1, arg2, arg3, arg4))->start(); -} - -template -auto run(Functor functor, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) - -> typename std::enable_if::Value, QFuture>::type -{ - typedef decltype(functor(arg1, arg2, arg3, arg4, arg5)) result_type; - return (new StoredFunctorCall5(functor, arg1, arg2, arg3, arg4, arg5))->start(); -} - -template -QFuture run(FunctionObject functionObject) -{ - return (new StoredFunctorCall0(functionObject))->start(); -} -template -QFuture run(FunctionObject functionObject, const Arg1 &arg1) -{ - return (new StoredFunctorCall1(functionObject, arg1))->start(); -} -template -QFuture run(FunctionObject functionObject, const Arg1 &arg1, const Arg2 &arg2) -{ - return (new StoredFunctorCall2(functionObject, arg1, arg2))->start(); -} -template -QFuture run(FunctionObject functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) -{ - return (new StoredFunctorCall3(functionObject, arg1, arg2, arg3))->start(); -} -template -QFuture run(FunctionObject functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) -{ - return (new StoredFunctorCall4(functionObject, arg1, arg2, arg3, arg4))->start(); -} -template -QFuture run(FunctionObject functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) -{ - return (new StoredFunctorCall5(functionObject, arg1, arg2, arg3, arg4, arg5))->start(); -} - -template -QFuture run(FunctionObject *functionObject) -{ - return (new typename SelectStoredFunctorPointerCall0::type(functionObject))->start(); -} -template -QFuture run(FunctionObject *functionObject, const Arg1 &arg1) -{ - return (new typename SelectStoredFunctorPointerCall1::type(functionObject, arg1))->start(); -} -template -QFuture run(FunctionObject *functionObject, const Arg1 &arg1, const Arg2 &arg2) -{ - return (new typename SelectStoredFunctorPointerCall2::type(functionObject, arg1, arg2))->start(); -} -template -QFuture run(FunctionObject *functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) -{ - return (new typename SelectStoredFunctorPointerCall3::type(functionObject, arg1, arg2, arg3))->start(); -} -template -QFuture run(FunctionObject *functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) -{ - return (new typename SelectStoredFunctorPointerCall4::type(functionObject, arg1, arg2, arg3, arg4))->start(); -} -template -QFuture run(FunctionObject *functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) -{ - return (new typename SelectStoredFunctorPointerCall5::type(functionObject, arg1, arg2, arg3, arg4, arg5))->start(); -} - -template -QFuture run(const Class &object, T (Class::*fn)()) -{ - return (new typename SelectStoredMemberFunctionCall0::type(fn, object))->start(); -} -template -QFuture run(const Class &object, T (Class::*fn)(Param1), const Arg1 &arg1) -{ - return (new typename SelectStoredMemberFunctionCall1::type(fn, object, arg1))->start(); -} -template -QFuture run(const Class &object, T (Class::*fn)(Param1, Param2), const Arg1 &arg1, const Arg2 &arg2) -{ - return (new typename SelectStoredMemberFunctionCall2::type(fn, object, arg1, arg2))->start(); -} -template -QFuture run(const Class &object, T (Class::*fn)(Param1, Param2, Param3), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) -{ - return (new typename SelectStoredMemberFunctionCall3::type(fn, object, arg1, arg2, arg3))->start(); -} -template -QFuture run(const Class &object, T (Class::*fn)(Param1, Param2, Param3, Param4), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) -{ - return (new typename SelectStoredMemberFunctionCall4::type(fn, object, arg1, arg2, arg3, arg4))->start(); -} -template -QFuture run(const Class &object, T (Class::*fn)(Param1, Param2, Param3, Param4, Param5), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) -{ - return (new typename SelectStoredMemberFunctionCall5::type(fn, object, arg1, arg2, arg3, arg4, arg5))->start(); -} - -template -QFuture run(const Class &object, T (Class::*fn)() const) -{ - return (new typename SelectStoredConstMemberFunctionCall0::type(fn, object))->start(); -} -template -QFuture run(const Class &object, T (Class::*fn)(Param1) const, const Arg1 &arg1) -{ - return (new typename SelectStoredConstMemberFunctionCall1::type(fn, object, arg1))->start(); -} -template -QFuture run(const Class &object, T (Class::*fn)(Param1, Param2) const, const Arg1 &arg1, const Arg2 &arg2) -{ - return (new typename SelectStoredConstMemberFunctionCall2::type(fn, object, arg1, arg2))->start(); -} -template -QFuture run(const Class &object, T (Class::*fn)(Param1, Param2, Param3) const, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) -{ - return (new typename SelectStoredConstMemberFunctionCall3::type(fn, object, arg1, arg2, arg3))->start(); -} -template -QFuture run(const Class &object, T (Class::*fn)(Param1, Param2, Param3, Param4) const, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) -{ - return (new typename SelectStoredConstMemberFunctionCall4::type(fn, object, arg1, arg2, arg3, arg4))->start(); -} -template -QFuture run(const Class &object, T (Class::*fn)(Param1, Param2, Param3, Param4, Param5) const, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) -{ - return (new typename SelectStoredConstMemberFunctionCall5::type(fn, object, arg1, arg2, arg3, arg4, arg5))->start(); -} - -template -QFuture run(Class *object, T (Class::*fn)()) -{ - return (new typename SelectStoredMemberFunctionPointerCall0::type(fn, object))->start(); -} -template -QFuture run(Class *object, T (Class::*fn)(Param1), const Arg1 &arg1) -{ - return (new typename SelectStoredMemberFunctionPointerCall1::type(fn, object, arg1))->start(); -} -template -QFuture run(Class *object, T (Class::*fn)(Param1, Param2), const Arg1 &arg1, const Arg2 &arg2) -{ - return (new typename SelectStoredMemberFunctionPointerCall2::type(fn, object, arg1, arg2))->start(); -} -template -QFuture run(Class *object, T (Class::*fn)(Param1, Param2, Param3), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) -{ - return (new typename SelectStoredMemberFunctionPointerCall3::type(fn, object, arg1, arg2, arg3))->start(); -} -template -QFuture run(Class *object, T (Class::*fn)(Param1, Param2, Param3, Param4), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) -{ - return (new typename SelectStoredMemberFunctionPointerCall4::type(fn, object, arg1, arg2, arg3, arg4))->start(); -} -template -QFuture run(Class *object, T (Class::*fn)(Param1, Param2, Param3, Param4, Param5), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) -{ - return (new typename SelectStoredMemberFunctionPointerCall5::type(fn, object, arg1, arg2, arg3, arg4, arg5))->start(); -} - -template -QFuture run(const Class *object, T (Class::*fn)() const) -{ - return (new typename SelectStoredConstMemberFunctionPointerCall0::type(fn, object))->start(); -} -template -QFuture run(const Class *object, T (Class::*fn)(Param1) const, const Arg1 &arg1) -{ - return (new typename SelectStoredConstMemberFunctionPointerCall1::type(fn, object, arg1))->start(); -} -template -QFuture run(const Class *object, T (Class::*fn)(Param1, Param2) const, const Arg1 &arg1, const Arg2 &arg2) -{ - return (new typename SelectStoredConstMemberFunctionPointerCall2::type(fn, object, arg1, arg2))->start(); -} -template -QFuture run(const Class *object, T (Class::*fn)(Param1, Param2, Param3) const, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) -{ - return (new typename SelectStoredConstMemberFunctionPointerCall3::type(fn, object, arg1, arg2, arg3))->start(); -} -template -QFuture run(const Class *object, T (Class::*fn)(Param1, Param2, Param3, Param4) const, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) -{ - return (new typename SelectStoredConstMemberFunctionPointerCall4::type(fn, object, arg1, arg2, arg3, arg4))->start(); -} -template -QFuture run(const Class *object, T (Class::*fn)(Param1, Param2, Param3, Param4, Param5) const, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) -{ - return (new typename SelectStoredConstMemberFunctionPointerCall5::type(fn, object, arg1, arg2, arg3, arg4, arg5))->start(); -} - -// ...and the same with a QThreadPool *pool argument... -// generate from the above by c'n'p and s/run(/run(QThreadPool *pool, / and s/start()/start(pool)/ - -template -QFuture run(QThreadPool *pool, T (*functionPointer)()) -{ - return (new StoredFunctorCall0(functionPointer))->start(pool); -} -template -QFuture run(QThreadPool *pool, T (*functionPointer)(Param1), const Arg1 &arg1) -{ - return (new StoredFunctorCall1(functionPointer, arg1))->start(pool); -} -template -QFuture run(QThreadPool *pool, T (*functionPointer)(Param1, Param2), const Arg1 &arg1, const Arg2 &arg2) -{ - return (new StoredFunctorCall2(functionPointer, arg1, arg2))->start(pool); -} -template -QFuture run(QThreadPool *pool, T (*functionPointer)(Param1, Param2, Param3), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) -{ - return (new StoredFunctorCall3(functionPointer, arg1, arg2, arg3))->start(pool); -} -template -QFuture run(QThreadPool *pool, T (*functionPointer)(Param1, Param2, Param3, Param4), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) -{ - return (new StoredFunctorCall4(functionPointer, arg1, arg2, arg3, arg4))->start(pool); -} -template -QFuture run(QThreadPool *pool, T (*functionPointer)(Param1, Param2, Param3, Param4, Param5), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) -{ - return (new StoredFunctorCall5(functionPointer, arg1, arg2, arg3, arg4, arg5))->start(pool); -} - -template -auto run(QThreadPool *pool, Functor functor) -> typename std::enable_if::Value, QFuture>::type -{ - typedef decltype(functor()) result_type; - return (new StoredFunctorCall0(functor))->start(pool); -} - -template -auto run(QThreadPool *pool, Functor functor, const Arg1 &arg1) - -> typename std::enable_if::Value, QFuture>::type -{ - typedef decltype(functor(arg1)) result_type; - return (new StoredFunctorCall1(functor, arg1))->start(pool); -} - -template -auto run(QThreadPool *pool, Functor functor, const Arg1 &arg1, const Arg2 &arg2) - -> typename std::enable_if::Value, QFuture>::type -{ - typedef decltype(functor(arg1, arg2)) result_type; - return (new StoredFunctorCall2(functor, arg1, arg2))->start(pool); + return (new StoredFunctionCall( + std::forward(f), std::forward(args)...))->start(pool); } -template -auto run(QThreadPool *pool, Functor functor, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) - -> typename std::enable_if::Value, QFuture>::type -{ - typedef decltype(functor(arg1, arg2, arg3)) result_type; - return (new StoredFunctorCall3(functor, arg1, arg2, arg3))->start(pool); -} - -template -auto run(QThreadPool *pool, Functor functor, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) - -> typename std::enable_if::Value, QFuture>::type -{ - typedef decltype(functor(arg1, arg2, arg3, arg4)) result_type; - return (new StoredFunctorCall4(functor, arg1, arg2, arg3, arg4))->start(pool); -} - -template -auto run(QThreadPool *pool, Functor functor, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) - -> typename std::enable_if::Value, QFuture>::type -{ - typedef decltype(functor(arg1, arg2, arg3, arg4, arg5)) result_type; - return (new StoredFunctorCall5(functor, arg1, arg2, arg3, arg4, arg5))->start(pool); -} - -template -QFuture run(QThreadPool *pool, FunctionObject functionObject) -{ - return (new StoredFunctorCall0(functionObject))->start(pool); -} -template -QFuture run(QThreadPool *pool, FunctionObject functionObject, const Arg1 &arg1) -{ - return (new StoredFunctorCall1(functionObject, arg1))->start(pool); -} -template -QFuture run(QThreadPool *pool, FunctionObject functionObject, const Arg1 &arg1, const Arg2 &arg2) -{ - return (new StoredFunctorCall2(functionObject, arg1, arg2))->start(pool); -} -template -QFuture run(QThreadPool *pool, FunctionObject functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) -{ - return (new StoredFunctorCall3(functionObject, arg1, arg2, arg3))->start(pool); -} -template -QFuture run(QThreadPool *pool, FunctionObject functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) -{ - return (new StoredFunctorCall4(functionObject, arg1, arg2, arg3, arg4))->start(pool); -} -template -QFuture run(QThreadPool *pool, FunctionObject functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) -{ - return (new StoredFunctorCall5(functionObject, arg1, arg2, arg3, arg4, arg5))->start(pool); -} - -template -QFuture run(QThreadPool *pool, FunctionObject *functionObject) -{ - return (new typename SelectStoredFunctorPointerCall0::type(functionObject))->start(pool); -} -template -QFuture run(QThreadPool *pool, FunctionObject *functionObject, const Arg1 &arg1) -{ - return (new typename SelectStoredFunctorPointerCall1::type(functionObject, arg1))->start(pool); -} -template -QFuture run(QThreadPool *pool, FunctionObject *functionObject, const Arg1 &arg1, const Arg2 &arg2) -{ - return (new typename SelectStoredFunctorPointerCall2::type(functionObject, arg1, arg2))->start(pool); -} -template -QFuture run(QThreadPool *pool, FunctionObject *functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) -{ - return (new typename SelectStoredFunctorPointerCall3::type(functionObject, arg1, arg2, arg3))->start(pool); -} -template -QFuture run(QThreadPool *pool, FunctionObject *functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) -{ - return (new typename SelectStoredFunctorPointerCall4::type(functionObject, arg1, arg2, arg3, arg4))->start(pool); -} -template -QFuture run(QThreadPool *pool, FunctionObject *functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) -{ - return (new typename SelectStoredFunctorPointerCall5::type(functionObject, arg1, arg2, arg3, arg4, arg5))->start(pool); -} - -template -QFuture run(QThreadPool *pool, const Class &object, T (Class::*fn)()) -{ - return (new typename SelectStoredMemberFunctionCall0::type(fn, object))->start(pool); -} -template -QFuture run(QThreadPool *pool, const Class &object, T (Class::*fn)(Param1), const Arg1 &arg1) -{ - return (new typename SelectStoredMemberFunctionCall1::type(fn, object, arg1))->start(pool); -} -template -QFuture run(QThreadPool *pool, const Class &object, T (Class::*fn)(Param1, Param2), const Arg1 &arg1, const Arg2 &arg2) -{ - return (new typename SelectStoredMemberFunctionCall2::type(fn, object, arg1, arg2))->start(pool); -} -template -QFuture run(QThreadPool *pool, const Class &object, T (Class::*fn)(Param1, Param2, Param3), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) -{ - return (new typename SelectStoredMemberFunctionCall3::type(fn, object, arg1, arg2, arg3))->start(pool); -} -template -QFuture run(QThreadPool *pool, const Class &object, T (Class::*fn)(Param1, Param2, Param3, Param4), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) +template +[[nodiscard]] +auto run(Function &&f, Args &&...args) { - return (new typename SelectStoredMemberFunctionCall4::type(fn, object, arg1, arg2, arg3, arg4))->start(pool); + return run(QThreadPool::globalInstance(), std::forward(f), std::forward(args)...); } -template -QFuture run(QThreadPool *pool, const Class &object, T (Class::*fn)(Param1, Param2, Param3, Param4, Param5), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) -{ - return (new typename SelectStoredMemberFunctionCall5::type(fn, object, arg1, arg2, arg3, arg4, arg5))->start(pool); -} - -template -QFuture run(QThreadPool *pool, const Class &object, T (Class::*fn)() const) -{ - return (new typename SelectStoredConstMemberFunctionCall0::type(fn, object))->start(pool); -} -template -QFuture run(QThreadPool *pool, const Class &object, T (Class::*fn)(Param1) const, const Arg1 &arg1) -{ - return (new typename SelectStoredConstMemberFunctionCall1::type(fn, object, arg1))->start(pool); -} -template -QFuture run(QThreadPool *pool, const Class &object, T (Class::*fn)(Param1, Param2) const, const Arg1 &arg1, const Arg2 &arg2) -{ - return (new typename SelectStoredConstMemberFunctionCall2::type(fn, object, arg1, arg2))->start(pool); -} -template -QFuture run(QThreadPool *pool, const Class &object, T (Class::*fn)(Param1, Param2, Param3) const, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) -{ - return (new typename SelectStoredConstMemberFunctionCall3::type(fn, object, arg1, arg2, arg3))->start(pool); -} -template -QFuture run(QThreadPool *pool, const Class &object, T (Class::*fn)(Param1, Param2, Param3, Param4) const, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) -{ - return (new typename SelectStoredConstMemberFunctionCall4::type(fn, object, arg1, arg2, arg3, arg4))->start(pool); -} -template -QFuture run(QThreadPool *pool, const Class &object, T (Class::*fn)(Param1, Param2, Param3, Param4, Param5) const, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) -{ - return (new typename SelectStoredConstMemberFunctionCall5::type(fn, object, arg1, arg2, arg3, arg4, arg5))->start(pool); -} - -template -QFuture run(QThreadPool *pool, Class *object, T (Class::*fn)()) -{ - return (new typename SelectStoredMemberFunctionPointerCall0::type(fn, object))->start(pool); -} -template -QFuture run(QThreadPool *pool, Class *object, T (Class::*fn)(Param1), const Arg1 &arg1) -{ - return (new typename SelectStoredMemberFunctionPointerCall1::type(fn, object, arg1))->start(pool); -} -template -QFuture run(QThreadPool *pool, Class *object, T (Class::*fn)(Param1, Param2), const Arg1 &arg1, const Arg2 &arg2) -{ - return (new typename SelectStoredMemberFunctionPointerCall2::type(fn, object, arg1, arg2))->start(pool); -} -template -QFuture run(QThreadPool *pool, Class *object, T (Class::*fn)(Param1, Param2, Param3), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) -{ - return (new typename SelectStoredMemberFunctionPointerCall3::type(fn, object, arg1, arg2, arg3))->start(pool); -} -template -QFuture run(QThreadPool *pool, Class *object, T (Class::*fn)(Param1, Param2, Param3, Param4), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) -{ - return (new typename SelectStoredMemberFunctionPointerCall4::type(fn, object, arg1, arg2, arg3, arg4))->start(pool); -} -template -QFuture run(QThreadPool *pool, Class *object, T (Class::*fn)(Param1, Param2, Param3, Param4, Param5), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) -{ - return (new typename SelectStoredMemberFunctionPointerCall5::type(fn, object, arg1, arg2, arg3, arg4, arg5))->start(pool); -} - -template -QFuture run(QThreadPool *pool, const Class *object, T (Class::*fn)() const) -{ - return (new typename SelectStoredConstMemberFunctionPointerCall0::type(fn, object))->start(pool); -} -template -QFuture run(QThreadPool *pool, const Class *object, T (Class::*fn)(Param1) const, const Arg1 &arg1) -{ - return (new typename SelectStoredConstMemberFunctionPointerCall1::type(fn, object, arg1))->start(pool); -} -template -QFuture run(QThreadPool *pool, const Class *object, T (Class::*fn)(Param1, Param2) const, const Arg1 &arg1, const Arg2 &arg2) -{ - return (new typename SelectStoredConstMemberFunctionPointerCall2::type(fn, object, arg1, arg2))->start(pool); -} -template -QFuture run(QThreadPool *pool, const Class *object, T (Class::*fn)(Param1, Param2, Param3) const, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) -{ - return (new typename SelectStoredConstMemberFunctionPointerCall3::type(fn, object, arg1, arg2, arg3))->start(pool); -} -template -QFuture run(QThreadPool *pool, const Class *object, T (Class::*fn)(Param1, Param2, Param3, Param4) const, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) -{ - return (new typename SelectStoredConstMemberFunctionPointerCall4::type(fn, object, arg1, arg2, arg3, arg4))->start(pool); -} -template -QFuture run(QThreadPool *pool, const Class *object, T (Class::*fn)(Param1, Param2, Param3, Param4, Param5) const, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) -{ - return (new typename SelectStoredConstMemberFunctionPointerCall5::type(fn, object, arg1, arg2, arg3, arg4, arg5))->start(pool); -} - -#if defined(__cpp_noexcept_function_type) && __cpp_noexcept_function_type >= 201510 -template -QFuture run(T (*functionPointer)() noexcept) -{ - return (new StoredFunctorCall0(functionPointer))->start(); -} -template -QFuture run(T (*functionPointer)(Param1) noexcept, const Arg1 &arg1) -{ - return (new StoredFunctorCall1(functionPointer, arg1))->start(); -} -template -QFuture run(T (*functionPointer)(Param1, Param2) noexcept, const Arg1 &arg1, const Arg2 &arg2) -{ - return (new StoredFunctorCall2(functionPointer, arg1, arg2))->start(); -} -template -QFuture run(T (*functionPointer)(Param1, Param2, Param3) noexcept, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) -{ - return (new StoredFunctorCall3(functionPointer, arg1, arg2, arg3))->start(); -} -template -QFuture run(T (*functionPointer)(Param1, Param2, Param3, Param4) noexcept, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) -{ - return (new StoredFunctorCall4(functionPointer, arg1, arg2, arg3, arg4))->start(); -} -template -QFuture run(T (*functionPointer)(Param1, Param2, Param3, Param4, Param5) noexcept, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) -{ - return (new StoredFunctorCall5(functionPointer, arg1, arg2, arg3, arg4, arg5))->start(); -} - -template -QFuture run(const Class &object, T (Class::*fn)() noexcept) -{ - return (new typename SelectStoredNoExceptMemberFunctionCall0::type(fn, object))->start(); -} -template -QFuture run(const Class &object, T (Class::*fn)(Param1) noexcept, const Arg1 &arg1) -{ - return (new typename SelectStoredNoExceptMemberFunctionCall1::type(fn, object, arg1))->start(); -} -template -QFuture run(const Class &object, T (Class::*fn)(Param1, Param2) noexcept, const Arg1 &arg1, const Arg2 &arg2) -{ - return (new typename SelectStoredNoExceptMemberFunctionCall2::type(fn, object, arg1, arg2))->start(); -} -template -QFuture run(const Class &object, T (Class::*fn)(Param1, Param2, Param3) noexcept, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) -{ - return (new typename SelectStoredNoExceptMemberFunctionCall3::type(fn, object, arg1, arg2, arg3))->start(); -} -template -QFuture run(const Class &object, T (Class::*fn)(Param1, Param2, Param3, Param4) noexcept, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) -{ - return (new typename SelectStoredNoExceptMemberFunctionCall4::type(fn, object, arg1, arg2, arg3, arg4))->start(); -} -template -QFuture run(const Class &object, T (Class::*fn)(Param1, Param2, Param3, Param4, Param5) noexcept, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) -{ - return (new typename SelectStoredNoExceptMemberFunctionCall5::type(fn, object, arg1, arg2, arg3, arg4, arg5))->start(); -} - -template -QFuture run(const Class &object, T (Class::*fn)() const noexcept) -{ - return (new typename SelectStoredConstNoExceptMemberFunctionCall0::type(fn, object))->start(); -} -template -QFuture run(const Class &object, T (Class::*fn)(Param1) const noexcept, const Arg1 &arg1) -{ - return (new typename SelectStoredConstNoExceptMemberFunctionCall1::type(fn, object, arg1))->start(); -} -template -QFuture run(const Class &object, T (Class::*fn)(Param1, Param2) const noexcept, const Arg1 &arg1, const Arg2 &arg2) -{ - return (new typename SelectStoredConstNoExceptMemberFunctionCall2::type(fn, object, arg1, arg2))->start(); -} -template -QFuture run(const Class &object, T (Class::*fn)(Param1, Param2, Param3) const noexcept, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) -{ - return (new typename SelectStoredConstNoExceptMemberFunctionCall3::type(fn, object, arg1, arg2, arg3))->start(); -} -template -QFuture run(const Class &object, T (Class::*fn)(Param1, Param2, Param3, Param4) const noexcept, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) -{ - return (new typename SelectStoredConstNoExceptMemberFunctionCall4::type(fn, object, arg1, arg2, arg3, arg4))->start(); -} -template -QFuture run(const Class &object, T (Class::*fn)(Param1, Param2, Param3, Param4, Param5) const noexcept, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) -{ - return (new typename SelectStoredConstNoExceptMemberFunctionCall5::type(fn, object, arg1, arg2, arg3, arg4, arg5))->start(); -} - -template -QFuture run(Class *object, T (Class::*fn)() noexcept) -{ - return (new typename SelectStoredNoExceptMemberFunctionPointerCall0::type(fn, object))->start(); -} -template -QFuture run(Class *object, T (Class::*fn)(Param1) noexcept, const Arg1 &arg1) -{ - return (new typename SelectStoredNoExceptMemberFunctionPointerCall1::type(fn, object, arg1))->start(); -} -template -QFuture run(Class *object, T (Class::*fn)(Param1, Param2) noexcept, const Arg1 &arg1, const Arg2 &arg2) -{ - return (new typename SelectStoredNoExceptMemberFunctionPointerCall2::type(fn, object, arg1, arg2))->start(); -} -template -QFuture run(Class *object, T (Class::*fn)(Param1, Param2, Param3) noexcept, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) -{ - return (new typename SelectStoredNoExceptMemberFunctionPointerCall3::type(fn, object, arg1, arg2, arg3))->start(); -} -template -QFuture run(Class *object, T (Class::*fn)(Param1, Param2, Param3, Param4) noexcept, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) -{ - return (new typename SelectStoredNoExceptMemberFunctionPointerCall4::type(fn, object, arg1, arg2, arg3, arg4))->start(); -} -template -QFuture run(Class *object, T (Class::*fn)(Param1, Param2, Param3, Param4, Param5) noexcept, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) -{ - return (new typename SelectStoredNoExceptMemberFunctionPointerCall5::type(fn, object, arg1, arg2, arg3, arg4, arg5))->start(); -} - -template -QFuture run(const Class *object, T (Class::*fn)() const noexcept) -{ - return (new typename SelectStoredConstNoExceptMemberFunctionPointerCall0::type(fn, object))->start(); -} -template -QFuture run(const Class *object, T (Class::*fn)(Param1) const noexcept, const Arg1 &arg1) -{ - return (new typename SelectStoredConstNoExceptMemberFunctionPointerCall1::type(fn, object, arg1))->start(); -} -template -QFuture run(const Class *object, T (Class::*fn)(Param1, Param2) const noexcept, const Arg1 &arg1, const Arg2 &arg2) -{ - return (new typename SelectStoredConstNoExceptMemberFunctionPointerCall2::type(fn, object, arg1, arg2))->start(); -} -template -QFuture run(const Class *object, T (Class::*fn)(Param1, Param2, Param3) const noexcept, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) -{ - return (new typename SelectStoredConstNoExceptMemberFunctionPointerCall3::type(fn, object, arg1, arg2, arg3))->start(); -} -template -QFuture run(const Class *object, T (Class::*fn)(Param1, Param2, Param3, Param4) const noexcept, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) -{ - return (new typename SelectStoredConstNoExceptMemberFunctionPointerCall4::type(fn, object, arg1, arg2, arg3, arg4))->start(); -} -template -QFuture run(const Class *object, T (Class::*fn)(Param1, Param2, Param3, Param4, Param5) const noexcept, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) -{ - return (new typename SelectStoredConstNoExceptMemberFunctionPointerCall5::type(fn, object, arg1, arg2, arg3, arg4, arg5))->start(); -} -template -QFuture run(QThreadPool *pool, T (*functionPointer)() noexcept) -{ - return (new StoredFunctorCall0(functionPointer))->start(pool); -} -template -QFuture run(QThreadPool *pool, T (*functionPointer)(Param1) noexcept, const Arg1 &arg1) -{ - return (new StoredFunctorCall1(functionPointer, arg1))->start(pool); -} -template -QFuture run(QThreadPool *pool, T (*functionPointer)(Param1, Param2) noexcept, const Arg1 &arg1, const Arg2 &arg2) -{ - return (new StoredFunctorCall2(functionPointer, arg1, arg2))->start(pool); -} -template -QFuture run(QThreadPool *pool, T (*functionPointer)(Param1, Param2, Param3) noexcept, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) -{ - return (new StoredFunctorCall3(functionPointer, arg1, arg2, arg3))->start(pool); -} -template -QFuture run(QThreadPool *pool, T (*functionPointer)(Param1, Param2, Param3, Param4) noexcept, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) -{ - return (new StoredFunctorCall4(functionPointer, arg1, arg2, arg3, arg4))->start(pool); -} -template -QFuture run(QThreadPool *pool, T (*functionPointer)(Param1, Param2, Param3, Param4, Param5) noexcept, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) -{ - return (new StoredFunctorCall5(functionPointer, arg1, arg2, arg3, arg4, arg5))->start(pool); -} - -template -QFuture run(QThreadPool *pool, const Class &object, T (Class::*fn)() noexcept) -{ - return (new typename SelectStoredNoExceptMemberFunctionCall0::type(fn, object))->start(pool); -} -template -QFuture run(QThreadPool *pool, const Class &object, T (Class::*fn)(Param1) noexcept, const Arg1 &arg1) -{ - return (new typename SelectStoredNoExceptMemberFunctionCall1::type(fn, object, arg1))->start(pool); -} -template -QFuture run(QThreadPool *pool, const Class &object, T (Class::*fn)(Param1, Param2) noexcept, const Arg1 &arg1, const Arg2 &arg2) -{ - return (new typename SelectStoredNoExceptMemberFunctionCall2::type(fn, object, arg1, arg2))->start(pool); -} -template -QFuture run(QThreadPool *pool, const Class &object, T (Class::*fn)(Param1, Param2, Param3) noexcept, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) -{ - return (new typename SelectStoredNoExceptMemberFunctionCall3::type(fn, object, arg1, arg2, arg3))->start(pool); -} -template -QFuture run(QThreadPool *pool, const Class &object, T (Class::*fn)(Param1, Param2, Param3, Param4) noexcept, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) -{ - return (new typename SelectStoredNoExceptMemberFunctionCall4::type(fn, object, arg1, arg2, arg3, arg4))->start(pool); -} -template -QFuture run(QThreadPool *pool, const Class &object, T (Class::*fn)(Param1, Param2, Param3, Param4, Param5) noexcept, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) -{ - return (new typename SelectStoredNoExceptMemberFunctionCall5::type(fn, object, arg1, arg2, arg3, arg4, arg5))->start(pool); -} - -template -QFuture run(QThreadPool *pool, const Class &object, T (Class::*fn)() const noexcept) -{ - return (new typename SelectStoredConstNoExceptMemberFunctionCall0::type(fn, object))->start(pool); -} -template -QFuture run(QThreadPool *pool, const Class &object, T (Class::*fn)(Param1) const noexcept, const Arg1 &arg1) -{ - return (new typename SelectStoredConstNoExceptMemberFunctionCall1::type(fn, object, arg1))->start(pool); -} -template -QFuture run(QThreadPool *pool, const Class &object, T (Class::*fn)(Param1, Param2) const noexcept, const Arg1 &arg1, const Arg2 &arg2) -{ - return (new typename SelectStoredConstNoExceptMemberFunctionCall2::type(fn, object, arg1, arg2))->start(pool); -} -template -QFuture run(QThreadPool *pool, const Class &object, T (Class::*fn)(Param1, Param2, Param3) const noexcept, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) -{ - return (new typename SelectStoredConstNoExceptMemberFunctionCall3::type(fn, object, arg1, arg2, arg3))->start(pool); -} -template -QFuture run(QThreadPool *pool, const Class &object, T (Class::*fn)(Param1, Param2, Param3, Param4) const noexcept, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) -{ - return (new typename SelectStoredConstNoExceptMemberFunctionCall4::type(fn, object, arg1, arg2, arg3, arg4))->start(pool); -} -template -QFuture run(QThreadPool *pool, const Class &object, T (Class::*fn)(Param1, Param2, Param3, Param4, Param5) const noexcept, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) -{ - return (new typename SelectStoredConstNoExceptMemberFunctionCall5::type(fn, object, arg1, arg2, arg3, arg4, arg5))->start(pool); -} - -template -QFuture run(QThreadPool *pool, Class *object, T (Class::*fn)() noexcept) -{ - return (new typename SelectStoredNoExceptMemberFunctionPointerCall0::type(fn, object))->start(pool); -} -template -QFuture run(QThreadPool *pool, Class *object, T (Class::*fn)(Param1) noexcept, const Arg1 &arg1) -{ - return (new typename SelectStoredNoExceptMemberFunctionPointerCall1::type(fn, object, arg1))->start(pool); -} -template -QFuture run(QThreadPool *pool, Class *object, T (Class::*fn)(Param1, Param2) noexcept, const Arg1 &arg1, const Arg2 &arg2) -{ - return (new typename SelectStoredNoExceptMemberFunctionPointerCall2::type(fn, object, arg1, arg2))->start(pool); -} -template -QFuture run(QThreadPool *pool, Class *object, T (Class::*fn)(Param1, Param2, Param3) noexcept, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) -{ - return (new typename SelectStoredNoExceptMemberFunctionPointerCall3::type(fn, object, arg1, arg2, arg3))->start(pool); -} -template -QFuture run(QThreadPool *pool, Class *object, T (Class::*fn)(Param1, Param2, Param3, Param4) noexcept, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) -{ - return (new typename SelectStoredNoExceptMemberFunctionPointerCall4::type(fn, object, arg1, arg2, arg3, arg4))->start(pool); -} -template -QFuture run(QThreadPool *pool, Class *object, T (Class::*fn)(Param1, Param2, Param3, Param4, Param5) noexcept, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) -{ - return (new typename SelectStoredNoExceptMemberFunctionPointerCall5::type(fn, object, arg1, arg2, arg3, arg4, arg5))->start(pool); -} - -template -QFuture run(QThreadPool *pool, const Class *object, T (Class::*fn)() const noexcept) -{ - return (new typename SelectStoredConstNoExceptMemberFunctionPointerCall0::type(fn, object))->start(pool); -} -template -QFuture run(QThreadPool *pool, const Class *object, T (Class::*fn)(Param1) const noexcept, const Arg1 &arg1) -{ - return (new typename SelectStoredConstNoExceptMemberFunctionPointerCall1::type(fn, object, arg1))->start(pool); -} -template -QFuture run(QThreadPool *pool, const Class *object, T (Class::*fn)(Param1, Param2) const noexcept, const Arg1 &arg1, const Arg2 &arg2) -{ - return (new typename SelectStoredConstNoExceptMemberFunctionPointerCall2::type(fn, object, arg1, arg2))->start(pool); -} -template -QFuture run(QThreadPool *pool, const Class *object, T (Class::*fn)(Param1, Param2, Param3) const noexcept, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) -{ - return (new typename SelectStoredConstNoExceptMemberFunctionPointerCall3::type(fn, object, arg1, arg2, arg3))->start(pool); -} -template -QFuture run(QThreadPool *pool, const Class *object, T (Class::*fn)(Param1, Param2, Param3, Param4) const noexcept, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) -{ - return (new typename SelectStoredConstNoExceptMemberFunctionPointerCall4::type(fn, object, arg1, arg2, arg3, arg4))->start(pool); -} -template -QFuture run(QThreadPool *pool, const Class *object, T (Class::*fn)(Param1, Param2, Param3, Param4, Param5) const noexcept, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) -{ - return (new typename SelectStoredConstNoExceptMemberFunctionPointerCall5::type(fn, object, arg1, arg2, arg3, arg4, arg5))->start(pool); -} -#endif } //namespace QtConcurrent diff --git a/src/concurrent/qtconcurrentstoredfunctioncall.h b/src/concurrent/qtconcurrentstoredfunctioncall.h index 209832e5bb..e2d0e3de0f 100644 --- a/src/concurrent/qtconcurrentstoredfunctioncall.h +++ b/src/concurrent/qtconcurrentstoredfunctioncall.h @@ -37,7 +37,6 @@ ** ****************************************************************************/ -// Generated code, do not edit! Use generator at tools/qtconcurrent/generaterun/ #ifndef QTCONCURRENT_STOREDFUNCTIONCALL_H #define QTCONCURRENT_STOREDFUNCTIONCALL_H @@ -45,6 +44,7 @@ #ifndef QT_NO_CONCURRENT #include +#include QT_BEGIN_NAMESPACE @@ -52,2204 +52,50 @@ QT_BEGIN_NAMESPACE #ifndef Q_QDOC namespace QtConcurrent { -template -struct StoredFunctorCall0: public RunFunctionTask -{ - inline StoredFunctorCall0(FunctionPointer _function) - : function(_function) {} - void runFunctor() override { this->result = function(); } - FunctionPointer function; - -}; - -template -struct StoredFunctorCall0: public RunFunctionTask -{ - inline StoredFunctorCall0(FunctionPointer _function) - : function(_function) {} - void runFunctor() override { function(); } - FunctionPointer function; - -}; - -template -struct StoredFunctorPointerCall0: public RunFunctionTask -{ - inline StoredFunctorPointerCall0(FunctionPointer * _function) - : function(_function) {} - void runFunctor() override { this->result =(*function)(); } - FunctionPointer * function; - -}; - -template -struct VoidStoredFunctorPointerCall0: public RunFunctionTask -{ - inline VoidStoredFunctorPointerCall0(FunctionPointer * _function) - : function(_function) {} - void runFunctor() override { (*function)(); } - FunctionPointer * function; - -}; - -template -struct SelectStoredFunctorPointerCall0 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredFunctorPointerCall0 >::type type; -}; -template -class StoredMemberFunctionCall0 : public RunFunctionTask -{ -public: - StoredMemberFunctionCall0(T (Class::*_fn)(), const Class &_object) - : fn(_fn), object(_object){ } - - void runFunctor() override - { - this->result = (object.*fn)(); - } -private: - T (Class::*fn)(); - Class object; - -}; -template -class VoidStoredMemberFunctionCall0 : public RunFunctionTask -{ -public: - VoidStoredMemberFunctionCall0(T (Class::*_fn)(), const Class &_object) - : fn(_fn), object(_object){ } - - void runFunctor() override - { - (object.*fn)(); - } -private: - T (Class::*fn)(); - Class object; - -}; -template -struct SelectStoredMemberFunctionCall0 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredMemberFunctionCall0 >::type type; -}; -template -class StoredConstMemberFunctionCall0 : public RunFunctionTask -{ -public: - StoredConstMemberFunctionCall0(T (Class::*_fn)() const, const Class &_object) - : fn(_fn), object(_object){ } - - void runFunctor() override - { - this->result = (object.*fn)(); - } -private: - T (Class::*fn)() const; - const Class object; - -}; -template -class VoidStoredConstMemberFunctionCall0 : public RunFunctionTask -{ -public: - VoidStoredConstMemberFunctionCall0(T (Class::*_fn)() const, const Class &_object) - : fn(_fn), object(_object){ } - - void runFunctor() override - { - (object.*fn)(); - } -private: - T (Class::*fn)() const; - const Class object; - -}; -template -struct SelectStoredConstMemberFunctionCall0 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredConstMemberFunctionCall0 >::type type; -}; -template -class StoredMemberFunctionPointerCall0 : public RunFunctionTask -{ -public: - StoredMemberFunctionPointerCall0(T (Class::*_fn)(), Class *_object) - : fn(_fn), object(_object){ } - - void runFunctor() override - { - this->result = (object->*fn)(); - } -private: - T (Class::*fn)(); - Class *object; - -}; -template -class VoidStoredMemberFunctionPointerCall0 : public RunFunctionTask -{ -public: - VoidStoredMemberFunctionPointerCall0(T (Class::*_fn)(), Class *_object) - : fn(_fn), object(_object){ } - - void runFunctor() override - { - (object->*fn)(); - } -private: - T (Class::*fn)(); - Class *object; - -}; -template -struct SelectStoredMemberFunctionPointerCall0 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredMemberFunctionPointerCall0 >::type type; -}; -template -class StoredConstMemberFunctionPointerCall0 : public RunFunctionTask -{ -public: - StoredConstMemberFunctionPointerCall0(T (Class::*_fn)() const, Class const *_object) - : fn(_fn), object(_object){ } - - void runFunctor() override - { - this->result = (object->*fn)(); - } -private: - T (Class::*fn)() const; - Class const *object; - -}; -template -class VoidStoredConstMemberFunctionPointerCall0 : public RunFunctionTask -{ -public: - VoidStoredConstMemberFunctionPointerCall0(T (Class::*_fn)() const, Class const *_object) - : fn(_fn), object(_object){ } - - void runFunctor() override - { - (object->*fn)(); - } -private: - T (Class::*fn)() const; - Class const *object; - -}; -template -struct SelectStoredConstMemberFunctionPointerCall0 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredConstMemberFunctionPointerCall0 >::type type; -}; -#if defined(__cpp_noexcept_function_type) && __cpp_noexcept_function_type >= 201510 -template -class StoredNoExceptMemberFunctionCall0 : public RunFunctionTask -{ -public: - StoredNoExceptMemberFunctionCall0(T (Class::*_fn)() noexcept, const Class &_object) - : fn(_fn), object(_object){ } - - void runFunctor() override - { - this->result = (object.*fn)(); - } -private: - T (Class::*fn)() noexcept; - Class object; - -}; -template -class VoidStoredNoExceptMemberFunctionCall0 : public RunFunctionTask -{ -public: - VoidStoredNoExceptMemberFunctionCall0(T (Class::*_fn)() noexcept, const Class &_object) - : fn(_fn), object(_object){ } - - void runFunctor() override - { - (object.*fn)(); - } -private: - T (Class::*fn)() noexcept; - Class object; - -}; -template -struct SelectStoredNoExceptMemberFunctionCall0 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredNoExceptMemberFunctionCall0 >::type type; -}; -template -class StoredConstNoExceptMemberFunctionCall0 : public RunFunctionTask -{ -public: - StoredConstNoExceptMemberFunctionCall0(T (Class::*_fn)() const noexcept, const Class &_object) - : fn(_fn), object(_object){ } - - void runFunctor() override - { - this->result = (object.*fn)(); - } -private: - T (Class::*fn)() const noexcept; - const Class object; - -}; -template -class VoidStoredConstNoExceptMemberFunctionCall0 : public RunFunctionTask -{ -public: - VoidStoredConstNoExceptMemberFunctionCall0(T (Class::*_fn)() const noexcept, const Class &_object) - : fn(_fn), object(_object){ } - - void runFunctor() override - { - (object.*fn)(); - } -private: - T (Class::*fn)() const noexcept; - const Class object; - -}; -template -struct SelectStoredConstNoExceptMemberFunctionCall0 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredConstNoExceptMemberFunctionCall0 >::type type; -}; -template -class StoredNoExceptMemberFunctionPointerCall0 : public RunFunctionTask -{ -public: - StoredNoExceptMemberFunctionPointerCall0(T (Class::*_fn)() noexcept, Class *_object) - : fn(_fn), object(_object){ } - - void runFunctor() override - { - this->result = (object->*fn)(); - } -private: - T (Class::*fn)() noexcept; - Class *object; - -}; -template -class VoidStoredNoExceptMemberFunctionPointerCall0 : public RunFunctionTask -{ -public: - VoidStoredNoExceptMemberFunctionPointerCall0(T (Class::*_fn)() noexcept, Class *_object) - : fn(_fn), object(_object){ } - - void runFunctor() override - { - (object->*fn)(); - } -private: - T (Class::*fn)() noexcept; - Class *object; - -}; -template -struct SelectStoredNoExceptMemberFunctionPointerCall0 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredNoExceptMemberFunctionPointerCall0 >::type type; -}; -template -class StoredConstNoExceptMemberFunctionPointerCall0 : public RunFunctionTask -{ -public: - StoredConstNoExceptMemberFunctionPointerCall0(T (Class::*_fn)() const noexcept, Class const *_object) - : fn(_fn), object(_object){ } - - void runFunctor() override - { - this->result = (object->*fn)(); - } -private: - T (Class::*fn)() const noexcept; - Class const *object; - -}; -template -class VoidStoredConstNoExceptMemberFunctionPointerCall0 : public RunFunctionTask -{ -public: - VoidStoredConstNoExceptMemberFunctionPointerCall0(T (Class::*_fn)() const noexcept, Class const *_object) - : fn(_fn), object(_object){ } - - void runFunctor() override - { - (object->*fn)(); - } -private: - T (Class::*fn)() const noexcept; - Class const *object; - -}; -template -struct SelectStoredConstNoExceptMemberFunctionPointerCall0 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredConstNoExceptMemberFunctionPointerCall0 >::type type; -}; -#endif - -template -struct StoredFunctorCall1: public RunFunctionTask -{ - inline StoredFunctorCall1(FunctionPointer _function, const Arg1 &_arg1) - : function(_function), arg1(_arg1) {} - void runFunctor() override { this->result = function(arg1); } - FunctionPointer function; - Arg1 arg1; -}; - -template -struct StoredFunctorCall1: public RunFunctionTask -{ - inline StoredFunctorCall1(FunctionPointer _function, const Arg1 &_arg1) - : function(_function), arg1(_arg1) {} - void runFunctor() override { function(arg1); } - FunctionPointer function; - Arg1 arg1; -}; - -template -struct StoredFunctorPointerCall1: public RunFunctionTask -{ - inline StoredFunctorPointerCall1(FunctionPointer * _function, const Arg1 &_arg1) - : function(_function), arg1(_arg1) {} - void runFunctor() override { this->result =(*function)(arg1); } - FunctionPointer * function; - Arg1 arg1; -}; - -template -struct VoidStoredFunctorPointerCall1: public RunFunctionTask -{ - inline VoidStoredFunctorPointerCall1(FunctionPointer * _function, const Arg1 &_arg1) - : function(_function), arg1(_arg1) {} - void runFunctor() override { (*function)(arg1); } - FunctionPointer * function; - Arg1 arg1; -}; - -template -struct SelectStoredFunctorPointerCall1 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredFunctorPointerCall1 >::type type; -}; -template -class StoredMemberFunctionCall1 : public RunFunctionTask -{ -public: - StoredMemberFunctionCall1(T (Class::*_fn)(Param1), const Class &_object, const Arg1 &_arg1) - : fn(_fn), object(_object), arg1(_arg1){ } - - void runFunctor() override - { - this->result = (object.*fn)(arg1); - } -private: - T (Class::*fn)(Param1); - Class object; - Arg1 arg1; -}; -template -class VoidStoredMemberFunctionCall1 : public RunFunctionTask -{ -public: - VoidStoredMemberFunctionCall1(T (Class::*_fn)(Param1), const Class &_object, const Arg1 &_arg1) - : fn(_fn), object(_object), arg1(_arg1){ } - - void runFunctor() override - { - (object.*fn)(arg1); - } -private: - T (Class::*fn)(Param1); - Class object; - Arg1 arg1; -}; -template -struct SelectStoredMemberFunctionCall1 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredMemberFunctionCall1 >::type type; -}; -template -class StoredConstMemberFunctionCall1 : public RunFunctionTask -{ -public: - StoredConstMemberFunctionCall1(T (Class::*_fn)(Param1) const, const Class &_object, const Arg1 &_arg1) - : fn(_fn), object(_object), arg1(_arg1){ } - - void runFunctor() override - { - this->result = (object.*fn)(arg1); - } -private: - T (Class::*fn)(Param1) const; - const Class object; - Arg1 arg1; -}; -template -class VoidStoredConstMemberFunctionCall1 : public RunFunctionTask -{ -public: - VoidStoredConstMemberFunctionCall1(T (Class::*_fn)(Param1) const, const Class &_object, const Arg1 &_arg1) - : fn(_fn), object(_object), arg1(_arg1){ } - - void runFunctor() override - { - (object.*fn)(arg1); - } -private: - T (Class::*fn)(Param1) const; - const Class object; - Arg1 arg1; -}; -template -struct SelectStoredConstMemberFunctionCall1 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredConstMemberFunctionCall1 >::type type; -}; -template -class StoredMemberFunctionPointerCall1 : public RunFunctionTask -{ -public: - StoredMemberFunctionPointerCall1(T (Class::*_fn)(Param1), Class *_object, const Arg1 &_arg1) - : fn(_fn), object(_object), arg1(_arg1){ } - - void runFunctor() override - { - this->result = (object->*fn)(arg1); - } -private: - T (Class::*fn)(Param1); - Class *object; - Arg1 arg1; -}; -template -class VoidStoredMemberFunctionPointerCall1 : public RunFunctionTask -{ -public: - VoidStoredMemberFunctionPointerCall1(T (Class::*_fn)(Param1), Class *_object, const Arg1 &_arg1) - : fn(_fn), object(_object), arg1(_arg1){ } - - void runFunctor() override - { - (object->*fn)(arg1); - } -private: - T (Class::*fn)(Param1); - Class *object; - Arg1 arg1; -}; -template -struct SelectStoredMemberFunctionPointerCall1 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredMemberFunctionPointerCall1 >::type type; -}; -template -class StoredConstMemberFunctionPointerCall1 : public RunFunctionTask -{ -public: - StoredConstMemberFunctionPointerCall1(T (Class::*_fn)(Param1) const, Class const *_object, const Arg1 &_arg1) - : fn(_fn), object(_object), arg1(_arg1){ } - - void runFunctor() override - { - this->result = (object->*fn)(arg1); - } -private: - T (Class::*fn)(Param1) const; - Class const *object; - Arg1 arg1; -}; -template -class VoidStoredConstMemberFunctionPointerCall1 : public RunFunctionTask -{ -public: - VoidStoredConstMemberFunctionPointerCall1(T (Class::*_fn)(Param1) const, Class const *_object, const Arg1 &_arg1) - : fn(_fn), object(_object), arg1(_arg1){ } - - void runFunctor() override - { - (object->*fn)(arg1); - } -private: - T (Class::*fn)(Param1) const; - Class const *object; - Arg1 arg1; -}; -template -struct SelectStoredConstMemberFunctionPointerCall1 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredConstMemberFunctionPointerCall1 >::type type; -}; -#if defined(__cpp_noexcept_function_type) && __cpp_noexcept_function_type >= 201510 -template -class StoredNoExceptMemberFunctionCall1 : public RunFunctionTask -{ -public: - StoredNoExceptMemberFunctionCall1(T (Class::*_fn)(Param1) noexcept, const Class &_object, const Arg1 &_arg1) - : fn(_fn), object(_object), arg1(_arg1){ } - - void runFunctor() override - { - this->result = (object.*fn)(arg1); - } -private: - T (Class::*fn)(Param1) noexcept; - Class object; - Arg1 arg1; -}; -template -class VoidStoredNoExceptMemberFunctionCall1 : public RunFunctionTask -{ -public: - VoidStoredNoExceptMemberFunctionCall1(T (Class::*_fn)(Param1) noexcept, const Class &_object, const Arg1 &_arg1) - : fn(_fn), object(_object), arg1(_arg1){ } - - void runFunctor() override - { - (object.*fn)(arg1); - } -private: - T (Class::*fn)(Param1) noexcept; - Class object; - Arg1 arg1; -}; -template -struct SelectStoredNoExceptMemberFunctionCall1 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredNoExceptMemberFunctionCall1 >::type type; -}; -template -class StoredConstNoExceptMemberFunctionCall1 : public RunFunctionTask -{ -public: - StoredConstNoExceptMemberFunctionCall1(T (Class::*_fn)(Param1) const noexcept, const Class &_object, const Arg1 &_arg1) - : fn(_fn), object(_object), arg1(_arg1){ } - - void runFunctor() override - { - this->result = (object.*fn)(arg1); - } -private: - T (Class::*fn)(Param1) const noexcept; - const Class object; - Arg1 arg1; -}; -template -class VoidStoredConstNoExceptMemberFunctionCall1 : public RunFunctionTask -{ -public: - VoidStoredConstNoExceptMemberFunctionCall1(T (Class::*_fn)(Param1) const noexcept, const Class &_object, const Arg1 &_arg1) - : fn(_fn), object(_object), arg1(_arg1){ } - - void runFunctor() override - { - (object.*fn)(arg1); - } -private: - T (Class::*fn)(Param1) const noexcept; - const Class object; - Arg1 arg1; -}; -template -struct SelectStoredConstNoExceptMemberFunctionCall1 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredConstNoExceptMemberFunctionCall1 >::type type; -}; -template -class StoredNoExceptMemberFunctionPointerCall1 : public RunFunctionTask -{ -public: - StoredNoExceptMemberFunctionPointerCall1(T (Class::*_fn)(Param1) noexcept, Class *_object, const Arg1 &_arg1) - : fn(_fn), object(_object), arg1(_arg1){ } - - void runFunctor() override - { - this->result = (object->*fn)(arg1); - } -private: - T (Class::*fn)(Param1) noexcept; - Class *object; - Arg1 arg1; -}; -template -class VoidStoredNoExceptMemberFunctionPointerCall1 : public RunFunctionTask -{ -public: - VoidStoredNoExceptMemberFunctionPointerCall1(T (Class::*_fn)(Param1) noexcept, Class *_object, const Arg1 &_arg1) - : fn(_fn), object(_object), arg1(_arg1){ } - - void runFunctor() override - { - (object->*fn)(arg1); - } -private: - T (Class::*fn)(Param1) noexcept; - Class *object; - Arg1 arg1; -}; -template -struct SelectStoredNoExceptMemberFunctionPointerCall1 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredNoExceptMemberFunctionPointerCall1 >::type type; -}; -template -class StoredConstNoExceptMemberFunctionPointerCall1 : public RunFunctionTask -{ -public: - StoredConstNoExceptMemberFunctionPointerCall1(T (Class::*_fn)(Param1) const noexcept, Class const *_object, const Arg1 &_arg1) - : fn(_fn), object(_object), arg1(_arg1){ } - - void runFunctor() override - { - this->result = (object->*fn)(arg1); - } -private: - T (Class::*fn)(Param1) const noexcept; - Class const *object; - Arg1 arg1; -}; -template -class VoidStoredConstNoExceptMemberFunctionPointerCall1 : public RunFunctionTask -{ -public: - VoidStoredConstNoExceptMemberFunctionPointerCall1(T (Class::*_fn)(Param1) const noexcept, Class const *_object, const Arg1 &_arg1) - : fn(_fn), object(_object), arg1(_arg1){ } - - void runFunctor() override - { - (object->*fn)(arg1); - } -private: - T (Class::*fn)(Param1) const noexcept; - Class const *object; - Arg1 arg1; -}; -template -struct SelectStoredConstNoExceptMemberFunctionPointerCall1 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredConstNoExceptMemberFunctionPointerCall1 >::type type; -}; -#endif - -template -struct StoredFunctorCall2: public RunFunctionTask -{ - inline StoredFunctorCall2(FunctionPointer _function, const Arg1 &_arg1, const Arg2 &_arg2) - : function(_function), arg1(_arg1), arg2(_arg2) {} - void runFunctor() override { this->result = function(arg1, arg2); } - FunctionPointer function; - Arg1 arg1; Arg2 arg2; -}; - -template -struct StoredFunctorCall2: public RunFunctionTask -{ - inline StoredFunctorCall2(FunctionPointer _function, const Arg1 &_arg1, const Arg2 &_arg2) - : function(_function), arg1(_arg1), arg2(_arg2) {} - void runFunctor() override { function(arg1, arg2); } - FunctionPointer function; - Arg1 arg1; Arg2 arg2; -}; - -template -struct StoredFunctorPointerCall2: public RunFunctionTask -{ - inline StoredFunctorPointerCall2(FunctionPointer * _function, const Arg1 &_arg1, const Arg2 &_arg2) - : function(_function), arg1(_arg1), arg2(_arg2) {} - void runFunctor() override { this->result =(*function)(arg1, arg2); } - FunctionPointer * function; - Arg1 arg1; Arg2 arg2; -}; - -template -struct VoidStoredFunctorPointerCall2: public RunFunctionTask -{ - inline VoidStoredFunctorPointerCall2(FunctionPointer * _function, const Arg1 &_arg1, const Arg2 &_arg2) - : function(_function), arg1(_arg1), arg2(_arg2) {} - void runFunctor() override { (*function)(arg1, arg2); } - FunctionPointer * function; - Arg1 arg1; Arg2 arg2; -}; - -template -struct SelectStoredFunctorPointerCall2 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredFunctorPointerCall2 >::type type; -}; -template -class StoredMemberFunctionCall2 : public RunFunctionTask -{ -public: - StoredMemberFunctionCall2(T (Class::*_fn)(Param1, Param2), const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2){ } - - void runFunctor() override - { - this->result = (object.*fn)(arg1, arg2); - } -private: - T (Class::*fn)(Param1, Param2); - Class object; - Arg1 arg1; Arg2 arg2; -}; -template -class VoidStoredMemberFunctionCall2 : public RunFunctionTask -{ -public: - VoidStoredMemberFunctionCall2(T (Class::*_fn)(Param1, Param2), const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2){ } - - void runFunctor() override - { - (object.*fn)(arg1, arg2); - } -private: - T (Class::*fn)(Param1, Param2); - Class object; - Arg1 arg1; Arg2 arg2; -}; -template -struct SelectStoredMemberFunctionCall2 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredMemberFunctionCall2 >::type type; -}; -template -class StoredConstMemberFunctionCall2 : public RunFunctionTask -{ -public: - StoredConstMemberFunctionCall2(T (Class::*_fn)(Param1, Param2) const, const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2){ } - - void runFunctor() override - { - this->result = (object.*fn)(arg1, arg2); - } -private: - T (Class::*fn)(Param1, Param2) const; - const Class object; - Arg1 arg1; Arg2 arg2; -}; -template -class VoidStoredConstMemberFunctionCall2 : public RunFunctionTask -{ -public: - VoidStoredConstMemberFunctionCall2(T (Class::*_fn)(Param1, Param2) const, const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2){ } - - void runFunctor() override - { - (object.*fn)(arg1, arg2); - } -private: - T (Class::*fn)(Param1, Param2) const; - const Class object; - Arg1 arg1; Arg2 arg2; -}; -template -struct SelectStoredConstMemberFunctionCall2 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredConstMemberFunctionCall2 >::type type; -}; -template -class StoredMemberFunctionPointerCall2 : public RunFunctionTask -{ -public: - StoredMemberFunctionPointerCall2(T (Class::*_fn)(Param1, Param2), Class *_object, const Arg1 &_arg1, const Arg2 &_arg2) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2){ } - - void runFunctor() override - { - this->result = (object->*fn)(arg1, arg2); - } -private: - T (Class::*fn)(Param1, Param2); - Class *object; - Arg1 arg1; Arg2 arg2; -}; -template -class VoidStoredMemberFunctionPointerCall2 : public RunFunctionTask -{ -public: - VoidStoredMemberFunctionPointerCall2(T (Class::*_fn)(Param1, Param2), Class *_object, const Arg1 &_arg1, const Arg2 &_arg2) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2){ } - - void runFunctor() override - { - (object->*fn)(arg1, arg2); - } -private: - T (Class::*fn)(Param1, Param2); - Class *object; - Arg1 arg1; Arg2 arg2; -}; -template -struct SelectStoredMemberFunctionPointerCall2 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredMemberFunctionPointerCall2 >::type type; -}; -template -class StoredConstMemberFunctionPointerCall2 : public RunFunctionTask -{ -public: - StoredConstMemberFunctionPointerCall2(T (Class::*_fn)(Param1, Param2) const, Class const *_object, const Arg1 &_arg1, const Arg2 &_arg2) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2){ } - - void runFunctor() override - { - this->result = (object->*fn)(arg1, arg2); - } -private: - T (Class::*fn)(Param1, Param2) const; - Class const *object; - Arg1 arg1; Arg2 arg2; -}; -template -class VoidStoredConstMemberFunctionPointerCall2 : public RunFunctionTask -{ -public: - VoidStoredConstMemberFunctionPointerCall2(T (Class::*_fn)(Param1, Param2) const, Class const *_object, const Arg1 &_arg1, const Arg2 &_arg2) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2){ } - - void runFunctor() override - { - (object->*fn)(arg1, arg2); - } -private: - T (Class::*fn)(Param1, Param2) const; - Class const *object; - Arg1 arg1; Arg2 arg2; -}; -template -struct SelectStoredConstMemberFunctionPointerCall2 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredConstMemberFunctionPointerCall2 >::type type; -}; -#if defined(__cpp_noexcept_function_type) && __cpp_noexcept_function_type >= 201510 -template -class StoredNoExceptMemberFunctionCall2 : public RunFunctionTask -{ -public: - StoredNoExceptMemberFunctionCall2(T (Class::*_fn)(Param1, Param2) noexcept, const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2){ } - - void runFunctor() override - { - this->result = (object.*fn)(arg1, arg2); - } -private: - T (Class::*fn)(Param1, Param2) noexcept; - Class object; - Arg1 arg1; Arg2 arg2; -}; -template -class VoidStoredNoExceptMemberFunctionCall2 : public RunFunctionTask -{ -public: - VoidStoredNoExceptMemberFunctionCall2(T (Class::*_fn)(Param1, Param2) noexcept, const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2){ } - - void runFunctor() override - { - (object.*fn)(arg1, arg2); - } -private: - T (Class::*fn)(Param1, Param2) noexcept; - Class object; - Arg1 arg1; Arg2 arg2; -}; -template -struct SelectStoredNoExceptMemberFunctionCall2 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredNoExceptMemberFunctionCall2 >::type type; -}; -template -class StoredConstNoExceptMemberFunctionCall2 : public RunFunctionTask -{ -public: - StoredConstNoExceptMemberFunctionCall2(T (Class::*_fn)(Param1, Param2) const noexcept, const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2){ } - - void runFunctor() override - { - this->result = (object.*fn)(arg1, arg2); - } -private: - T (Class::*fn)(Param1, Param2) const noexcept; - const Class object; - Arg1 arg1; Arg2 arg2; -}; -template -class VoidStoredConstNoExceptMemberFunctionCall2 : public RunFunctionTask -{ -public: - VoidStoredConstNoExceptMemberFunctionCall2(T (Class::*_fn)(Param1, Param2) const noexcept, const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2){ } - - void runFunctor() override - { - (object.*fn)(arg1, arg2); - } -private: - T (Class::*fn)(Param1, Param2) const noexcept; - const Class object; - Arg1 arg1; Arg2 arg2; -}; -template -struct SelectStoredConstNoExceptMemberFunctionCall2 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredConstNoExceptMemberFunctionCall2 >::type type; -}; -template -class StoredNoExceptMemberFunctionPointerCall2 : public RunFunctionTask -{ -public: - StoredNoExceptMemberFunctionPointerCall2(T (Class::*_fn)(Param1, Param2) noexcept, Class *_object, const Arg1 &_arg1, const Arg2 &_arg2) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2){ } - - void runFunctor() override - { - this->result = (object->*fn)(arg1, arg2); - } -private: - T (Class::*fn)(Param1, Param2) noexcept; - Class *object; - Arg1 arg1; Arg2 arg2; -}; -template -class VoidStoredNoExceptMemberFunctionPointerCall2 : public RunFunctionTask -{ -public: - VoidStoredNoExceptMemberFunctionPointerCall2(T (Class::*_fn)(Param1, Param2) noexcept, Class *_object, const Arg1 &_arg1, const Arg2 &_arg2) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2){ } - - void runFunctor() override - { - (object->*fn)(arg1, arg2); - } -private: - T (Class::*fn)(Param1, Param2) noexcept; - Class *object; - Arg1 arg1; Arg2 arg2; -}; -template -struct SelectStoredNoExceptMemberFunctionPointerCall2 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredNoExceptMemberFunctionPointerCall2 >::type type; -}; -template -class StoredConstNoExceptMemberFunctionPointerCall2 : public RunFunctionTask -{ -public: - StoredConstNoExceptMemberFunctionPointerCall2(T (Class::*_fn)(Param1, Param2) const noexcept, Class const *_object, const Arg1 &_arg1, const Arg2 &_arg2) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2){ } - - void runFunctor() override - { - this->result = (object->*fn)(arg1, arg2); - } -private: - T (Class::*fn)(Param1, Param2) const noexcept; - Class const *object; - Arg1 arg1; Arg2 arg2; -}; -template -class VoidStoredConstNoExceptMemberFunctionPointerCall2 : public RunFunctionTask -{ -public: - VoidStoredConstNoExceptMemberFunctionPointerCall2(T (Class::*_fn)(Param1, Param2) const noexcept, Class const *_object, const Arg1 &_arg1, const Arg2 &_arg2) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2){ } - - void runFunctor() override - { - (object->*fn)(arg1, arg2); - } -private: - T (Class::*fn)(Param1, Param2) const noexcept; - Class const *object; - Arg1 arg1; Arg2 arg2; -}; -template -struct SelectStoredConstNoExceptMemberFunctionPointerCall2 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredConstNoExceptMemberFunctionPointerCall2 >::type type; -}; -#endif - -template -struct StoredFunctorCall3: public RunFunctionTask -{ - inline StoredFunctorCall3(FunctionPointer _function, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3) - : function(_function), arg1(_arg1), arg2(_arg2), arg3(_arg3) {} - void runFunctor() override { this->result = function(arg1, arg2, arg3); } - FunctionPointer function; - Arg1 arg1; Arg2 arg2; Arg3 arg3; -}; - -template -struct StoredFunctorCall3: public RunFunctionTask -{ - inline StoredFunctorCall3(FunctionPointer _function, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3) - : function(_function), arg1(_arg1), arg2(_arg2), arg3(_arg3) {} - void runFunctor() override { function(arg1, arg2, arg3); } - FunctionPointer function; - Arg1 arg1; Arg2 arg2; Arg3 arg3; -}; - -template -struct StoredFunctorPointerCall3: public RunFunctionTask -{ - inline StoredFunctorPointerCall3(FunctionPointer * _function, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3) - : function(_function), arg1(_arg1), arg2(_arg2), arg3(_arg3) {} - void runFunctor() override { this->result =(*function)(arg1, arg2, arg3); } - FunctionPointer * function; - Arg1 arg1; Arg2 arg2; Arg3 arg3; -}; - -template -struct VoidStoredFunctorPointerCall3: public RunFunctionTask -{ - inline VoidStoredFunctorPointerCall3(FunctionPointer * _function, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3) - : function(_function), arg1(_arg1), arg2(_arg2), arg3(_arg3) {} - void runFunctor() override { (*function)(arg1, arg2, arg3); } - FunctionPointer * function; - Arg1 arg1; Arg2 arg2; Arg3 arg3; -}; - -template -struct SelectStoredFunctorPointerCall3 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredFunctorPointerCall3 >::type type; -}; -template -class StoredMemberFunctionCall3 : public RunFunctionTask -{ -public: - StoredMemberFunctionCall3(T (Class::*_fn)(Param1, Param2, Param3), const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3){ } - - void runFunctor() override - { - this->result = (object.*fn)(arg1, arg2, arg3); - } -private: - T (Class::*fn)(Param1, Param2, Param3); - Class object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; -}; -template -class VoidStoredMemberFunctionCall3 : public RunFunctionTask -{ -public: - VoidStoredMemberFunctionCall3(T (Class::*_fn)(Param1, Param2, Param3), const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3){ } - - void runFunctor() override - { - (object.*fn)(arg1, arg2, arg3); - } -private: - T (Class::*fn)(Param1, Param2, Param3); - Class object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; -}; -template -struct SelectStoredMemberFunctionCall3 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredMemberFunctionCall3 >::type type; -}; -template -class StoredConstMemberFunctionCall3 : public RunFunctionTask -{ -public: - StoredConstMemberFunctionCall3(T (Class::*_fn)(Param1, Param2, Param3) const, const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3){ } - - void runFunctor() override - { - this->result = (object.*fn)(arg1, arg2, arg3); - } -private: - T (Class::*fn)(Param1, Param2, Param3) const; - const Class object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; -}; -template -class VoidStoredConstMemberFunctionCall3 : public RunFunctionTask -{ -public: - VoidStoredConstMemberFunctionCall3(T (Class::*_fn)(Param1, Param2, Param3) const, const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3){ } - - void runFunctor() override - { - (object.*fn)(arg1, arg2, arg3); - } -private: - T (Class::*fn)(Param1, Param2, Param3) const; - const Class object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; -}; -template -struct SelectStoredConstMemberFunctionCall3 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredConstMemberFunctionCall3 >::type type; -}; -template -class StoredMemberFunctionPointerCall3 : public RunFunctionTask -{ -public: - StoredMemberFunctionPointerCall3(T (Class::*_fn)(Param1, Param2, Param3), Class *_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3){ } - - void runFunctor() override - { - this->result = (object->*fn)(arg1, arg2, arg3); - } -private: - T (Class::*fn)(Param1, Param2, Param3); - Class *object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; -}; -template -class VoidStoredMemberFunctionPointerCall3 : public RunFunctionTask -{ -public: - VoidStoredMemberFunctionPointerCall3(T (Class::*_fn)(Param1, Param2, Param3), Class *_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3){ } - - void runFunctor() override - { - (object->*fn)(arg1, arg2, arg3); - } -private: - T (Class::*fn)(Param1, Param2, Param3); - Class *object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; -}; -template -struct SelectStoredMemberFunctionPointerCall3 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredMemberFunctionPointerCall3 >::type type; -}; -template -class StoredConstMemberFunctionPointerCall3 : public RunFunctionTask -{ -public: - StoredConstMemberFunctionPointerCall3(T (Class::*_fn)(Param1, Param2, Param3) const, Class const *_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3){ } - - void runFunctor() override - { - this->result = (object->*fn)(arg1, arg2, arg3); - } -private: - T (Class::*fn)(Param1, Param2, Param3) const; - Class const *object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; -}; -template -class VoidStoredConstMemberFunctionPointerCall3 : public RunFunctionTask -{ -public: - VoidStoredConstMemberFunctionPointerCall3(T (Class::*_fn)(Param1, Param2, Param3) const, Class const *_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3){ } - - void runFunctor() override - { - (object->*fn)(arg1, arg2, arg3); - } -private: - T (Class::*fn)(Param1, Param2, Param3) const; - Class const *object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; -}; -template -struct SelectStoredConstMemberFunctionPointerCall3 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredConstMemberFunctionPointerCall3 >::type type; -}; -#if defined(__cpp_noexcept_function_type) && __cpp_noexcept_function_type >= 201510 -template -class StoredNoExceptMemberFunctionCall3 : public RunFunctionTask -{ -public: - StoredNoExceptMemberFunctionCall3(T (Class::*_fn)(Param1, Param2, Param3) noexcept, const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3){ } - - void runFunctor() override - { - this->result = (object.*fn)(arg1, arg2, arg3); - } -private: - T (Class::*fn)(Param1, Param2, Param3) noexcept; - Class object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; -}; -template -class VoidStoredNoExceptMemberFunctionCall3 : public RunFunctionTask -{ -public: - VoidStoredNoExceptMemberFunctionCall3(T (Class::*_fn)(Param1, Param2, Param3) noexcept, const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3){ } - - void runFunctor() override - { - (object.*fn)(arg1, arg2, arg3); - } -private: - T (Class::*fn)(Param1, Param2, Param3) noexcept; - Class object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; -}; -template -struct SelectStoredNoExceptMemberFunctionCall3 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredNoExceptMemberFunctionCall3 >::type type; -}; -template -class StoredConstNoExceptMemberFunctionCall3 : public RunFunctionTask -{ -public: - StoredConstNoExceptMemberFunctionCall3(T (Class::*_fn)(Param1, Param2, Param3) const noexcept, const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3){ } - - void runFunctor() override - { - this->result = (object.*fn)(arg1, arg2, arg3); - } -private: - T (Class::*fn)(Param1, Param2, Param3) const noexcept; - const Class object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; -}; -template -class VoidStoredConstNoExceptMemberFunctionCall3 : public RunFunctionTask -{ -public: - VoidStoredConstNoExceptMemberFunctionCall3(T (Class::*_fn)(Param1, Param2, Param3) const noexcept, const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3){ } - - void runFunctor() override - { - (object.*fn)(arg1, arg2, arg3); - } -private: - T (Class::*fn)(Param1, Param2, Param3) const noexcept; - const Class object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; -}; -template -struct SelectStoredConstNoExceptMemberFunctionCall3 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredConstNoExceptMemberFunctionCall3 >::type type; -}; -template -class StoredNoExceptMemberFunctionPointerCall3 : public RunFunctionTask -{ -public: - StoredNoExceptMemberFunctionPointerCall3(T (Class::*_fn)(Param1, Param2, Param3) noexcept, Class *_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3){ } - - void runFunctor() override - { - this->result = (object->*fn)(arg1, arg2, arg3); - } -private: - T (Class::*fn)(Param1, Param2, Param3) noexcept; - Class *object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; -}; -template -class VoidStoredNoExceptMemberFunctionPointerCall3 : public RunFunctionTask -{ -public: - VoidStoredNoExceptMemberFunctionPointerCall3(T (Class::*_fn)(Param1, Param2, Param3) noexcept, Class *_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3){ } - - void runFunctor() override - { - (object->*fn)(arg1, arg2, arg3); - } -private: - T (Class::*fn)(Param1, Param2, Param3) noexcept; - Class *object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; -}; -template -struct SelectStoredNoExceptMemberFunctionPointerCall3 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredNoExceptMemberFunctionPointerCall3 >::type type; -}; -template -class StoredConstNoExceptMemberFunctionPointerCall3 : public RunFunctionTask -{ -public: - StoredConstNoExceptMemberFunctionPointerCall3(T (Class::*_fn)(Param1, Param2, Param3) const noexcept, Class const *_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3){ } - - void runFunctor() override - { - this->result = (object->*fn)(arg1, arg2, arg3); - } -private: - T (Class::*fn)(Param1, Param2, Param3) const noexcept; - Class const *object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; -}; -template -class VoidStoredConstNoExceptMemberFunctionPointerCall3 : public RunFunctionTask -{ -public: - VoidStoredConstNoExceptMemberFunctionPointerCall3(T (Class::*_fn)(Param1, Param2, Param3) const noexcept, Class const *_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3){ } - - void runFunctor() override - { - (object->*fn)(arg1, arg2, arg3); - } -private: - T (Class::*fn)(Param1, Param2, Param3) const noexcept; - Class const *object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; -}; -template -struct SelectStoredConstNoExceptMemberFunctionPointerCall3 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredConstNoExceptMemberFunctionPointerCall3 >::type type; -}; -#endif - -template -struct StoredFunctorCall4: public RunFunctionTask -{ - inline StoredFunctorCall4(FunctionPointer _function, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4) - : function(_function), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4) {} - void runFunctor() override { this->result = function(arg1, arg2, arg3, arg4); } - FunctionPointer function; - Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; -}; - -template -struct StoredFunctorCall4: public RunFunctionTask -{ - inline StoredFunctorCall4(FunctionPointer _function, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4) - : function(_function), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4) {} - void runFunctor() override { function(arg1, arg2, arg3, arg4); } - FunctionPointer function; - Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; -}; - -template -struct StoredFunctorPointerCall4: public RunFunctionTask -{ - inline StoredFunctorPointerCall4(FunctionPointer * _function, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4) - : function(_function), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4) {} - void runFunctor() override { this->result =(*function)(arg1, arg2, arg3, arg4); } - FunctionPointer * function; - Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; -}; - -template -struct VoidStoredFunctorPointerCall4: public RunFunctionTask -{ - inline VoidStoredFunctorPointerCall4(FunctionPointer * _function, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4) - : function(_function), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4) {} - void runFunctor() override { (*function)(arg1, arg2, arg3, arg4); } - FunctionPointer * function; - Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; -}; - -template -struct SelectStoredFunctorPointerCall4 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredFunctorPointerCall4 >::type type; -}; -template -class StoredMemberFunctionCall4 : public RunFunctionTask -{ -public: - StoredMemberFunctionCall4(T (Class::*_fn)(Param1, Param2, Param3, Param4), const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4){ } - - void runFunctor() override - { - this->result = (object.*fn)(arg1, arg2, arg3, arg4); - } -private: - T (Class::*fn)(Param1, Param2, Param3, Param4); - Class object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; -}; -template -class VoidStoredMemberFunctionCall4 : public RunFunctionTask -{ -public: - VoidStoredMemberFunctionCall4(T (Class::*_fn)(Param1, Param2, Param3, Param4), const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4){ } - - void runFunctor() override - { - (object.*fn)(arg1, arg2, arg3, arg4); - } -private: - T (Class::*fn)(Param1, Param2, Param3, Param4); - Class object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; -}; -template -struct SelectStoredMemberFunctionCall4 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredMemberFunctionCall4 >::type type; -}; -template -class StoredConstMemberFunctionCall4 : public RunFunctionTask -{ -public: - StoredConstMemberFunctionCall4(T (Class::*_fn)(Param1, Param2, Param3, Param4) const, const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4){ } - - void runFunctor() override - { - this->result = (object.*fn)(arg1, arg2, arg3, arg4); - } -private: - T (Class::*fn)(Param1, Param2, Param3, Param4) const; - const Class object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; -}; -template -class VoidStoredConstMemberFunctionCall4 : public RunFunctionTask -{ -public: - VoidStoredConstMemberFunctionCall4(T (Class::*_fn)(Param1, Param2, Param3, Param4) const, const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4){ } - - void runFunctor() override - { - (object.*fn)(arg1, arg2, arg3, arg4); - } -private: - T (Class::*fn)(Param1, Param2, Param3, Param4) const; - const Class object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; -}; -template -struct SelectStoredConstMemberFunctionCall4 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredConstMemberFunctionCall4 >::type type; -}; -template -class StoredMemberFunctionPointerCall4 : public RunFunctionTask -{ -public: - StoredMemberFunctionPointerCall4(T (Class::*_fn)(Param1, Param2, Param3, Param4), Class *_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4){ } - - void runFunctor() override - { - this->result = (object->*fn)(arg1, arg2, arg3, arg4); - } -private: - T (Class::*fn)(Param1, Param2, Param3, Param4); - Class *object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; -}; -template -class VoidStoredMemberFunctionPointerCall4 : public RunFunctionTask -{ -public: - VoidStoredMemberFunctionPointerCall4(T (Class::*_fn)(Param1, Param2, Param3, Param4), Class *_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4){ } - - void runFunctor() override - { - (object->*fn)(arg1, arg2, arg3, arg4); - } -private: - T (Class::*fn)(Param1, Param2, Param3, Param4); - Class *object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; -}; -template -struct SelectStoredMemberFunctionPointerCall4 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredMemberFunctionPointerCall4 >::type type; -}; -template -class StoredConstMemberFunctionPointerCall4 : public RunFunctionTask -{ -public: - StoredConstMemberFunctionPointerCall4(T (Class::*_fn)(Param1, Param2, Param3, Param4) const, Class const *_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4){ } - - void runFunctor() override - { - this->result = (object->*fn)(arg1, arg2, arg3, arg4); - } -private: - T (Class::*fn)(Param1, Param2, Param3, Param4) const; - Class const *object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; -}; -template -class VoidStoredConstMemberFunctionPointerCall4 : public RunFunctionTask -{ -public: - VoidStoredConstMemberFunctionPointerCall4(T (Class::*_fn)(Param1, Param2, Param3, Param4) const, Class const *_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4){ } - - void runFunctor() override - { - (object->*fn)(arg1, arg2, arg3, arg4); - } -private: - T (Class::*fn)(Param1, Param2, Param3, Param4) const; - Class const *object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; -}; -template -struct SelectStoredConstMemberFunctionPointerCall4 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredConstMemberFunctionPointerCall4 >::type type; -}; -#if defined(__cpp_noexcept_function_type) && __cpp_noexcept_function_type >= 201510 -template -class StoredNoExceptMemberFunctionCall4 : public RunFunctionTask -{ -public: - StoredNoExceptMemberFunctionCall4(T (Class::*_fn)(Param1, Param2, Param3, Param4) noexcept, const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4){ } - - void runFunctor() override - { - this->result = (object.*fn)(arg1, arg2, arg3, arg4); - } -private: - T (Class::*fn)(Param1, Param2, Param3, Param4) noexcept; - Class object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; -}; -template -class VoidStoredNoExceptMemberFunctionCall4 : public RunFunctionTask -{ -public: - VoidStoredNoExceptMemberFunctionCall4(T (Class::*_fn)(Param1, Param2, Param3, Param4) noexcept, const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4){ } - - void runFunctor() override - { - (object.*fn)(arg1, arg2, arg3, arg4); - } -private: - T (Class::*fn)(Param1, Param2, Param3, Param4) noexcept; - Class object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; -}; -template -struct SelectStoredNoExceptMemberFunctionCall4 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredNoExceptMemberFunctionCall4 >::type type; -}; -template -class StoredConstNoExceptMemberFunctionCall4 : public RunFunctionTask -{ -public: - StoredConstNoExceptMemberFunctionCall4(T (Class::*_fn)(Param1, Param2, Param3, Param4) const noexcept, const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4){ } - - void runFunctor() override - { - this->result = (object.*fn)(arg1, arg2, arg3, arg4); - } -private: - T (Class::*fn)(Param1, Param2, Param3, Param4) const noexcept; - const Class object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; -}; -template -class VoidStoredConstNoExceptMemberFunctionCall4 : public RunFunctionTask -{ -public: - VoidStoredConstNoExceptMemberFunctionCall4(T (Class::*_fn)(Param1, Param2, Param3, Param4) const noexcept, const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4){ } - - void runFunctor() override - { - (object.*fn)(arg1, arg2, arg3, arg4); - } -private: - T (Class::*fn)(Param1, Param2, Param3, Param4) const noexcept; - const Class object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; -}; -template -struct SelectStoredConstNoExceptMemberFunctionCall4 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredConstNoExceptMemberFunctionCall4 >::type type; -}; -template -class StoredNoExceptMemberFunctionPointerCall4 : public RunFunctionTask -{ -public: - StoredNoExceptMemberFunctionPointerCall4(T (Class::*_fn)(Param1, Param2, Param3, Param4) noexcept, Class *_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4){ } - - void runFunctor() override - { - this->result = (object->*fn)(arg1, arg2, arg3, arg4); - } -private: - T (Class::*fn)(Param1, Param2, Param3, Param4) noexcept; - Class *object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; -}; -template -class VoidStoredNoExceptMemberFunctionPointerCall4 : public RunFunctionTask -{ -public: - VoidStoredNoExceptMemberFunctionPointerCall4(T (Class::*_fn)(Param1, Param2, Param3, Param4) noexcept, Class *_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4){ } - - void runFunctor() override - { - (object->*fn)(arg1, arg2, arg3, arg4); - } -private: - T (Class::*fn)(Param1, Param2, Param3, Param4) noexcept; - Class *object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; -}; -template -struct SelectStoredNoExceptMemberFunctionPointerCall4 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredNoExceptMemberFunctionPointerCall4 >::type type; -}; -template -class StoredConstNoExceptMemberFunctionPointerCall4 : public RunFunctionTask -{ -public: - StoredConstNoExceptMemberFunctionPointerCall4(T (Class::*_fn)(Param1, Param2, Param3, Param4) const noexcept, Class const *_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4){ } - - void runFunctor() override - { - this->result = (object->*fn)(arg1, arg2, arg3, arg4); - } -private: - T (Class::*fn)(Param1, Param2, Param3, Param4) const noexcept; - Class const *object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; -}; -template -class VoidStoredConstNoExceptMemberFunctionPointerCall4 : public RunFunctionTask -{ -public: - VoidStoredConstNoExceptMemberFunctionPointerCall4(T (Class::*_fn)(Param1, Param2, Param3, Param4) const noexcept, Class const *_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4){ } - - void runFunctor() override - { - (object->*fn)(arg1, arg2, arg3, arg4); - } -private: - T (Class::*fn)(Param1, Param2, Param3, Param4) const noexcept; - Class const *object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; -}; -template -struct SelectStoredConstNoExceptMemberFunctionPointerCall4 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredConstNoExceptMemberFunctionPointerCall4 >::type type; -}; -#endif - -template -struct StoredFunctorCall5: public RunFunctionTask -{ - inline StoredFunctorCall5(FunctionPointer _function, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4, const Arg5 &_arg5) - : function(_function), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4), arg5(_arg5) {} - void runFunctor() override { this->result = function(arg1, arg2, arg3, arg4, arg5); } - FunctionPointer function; - Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; Arg5 arg5; -}; - -template -struct StoredFunctorCall5: public RunFunctionTask -{ - inline StoredFunctorCall5(FunctionPointer _function, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4, const Arg5 &_arg5) - : function(_function), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4), arg5(_arg5) {} - void runFunctor() override { function(arg1, arg2, arg3, arg4, arg5); } - FunctionPointer function; - Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; Arg5 arg5; -}; - -template -struct StoredFunctorPointerCall5: public RunFunctionTask -{ - inline StoredFunctorPointerCall5(FunctionPointer * _function, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4, const Arg5 &_arg5) - : function(_function), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4), arg5(_arg5) {} - void runFunctor() override { this->result =(*function)(arg1, arg2, arg3, arg4, arg5); } - FunctionPointer * function; - Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; Arg5 arg5; -}; - -template -struct VoidStoredFunctorPointerCall5: public RunFunctionTask -{ - inline VoidStoredFunctorPointerCall5(FunctionPointer * _function, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4, const Arg5 &_arg5) - : function(_function), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4), arg5(_arg5) {} - void runFunctor() override { (*function)(arg1, arg2, arg3, arg4, arg5); } - FunctionPointer * function; - Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; Arg5 arg5; -}; - -template -struct SelectStoredFunctorPointerCall5 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredFunctorPointerCall5 >::type type; -}; -template -class StoredMemberFunctionCall5 : public RunFunctionTask -{ -public: - StoredMemberFunctionCall5(T (Class::*_fn)(Param1, Param2, Param3, Param4, Param5), const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4, const Arg5 &_arg5) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4), arg5(_arg5){ } - - void runFunctor() override - { - this->result = (object.*fn)(arg1, arg2, arg3, arg4, arg5); - } -private: - T (Class::*fn)(Param1, Param2, Param3, Param4, Param5); - Class object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; Arg5 arg5; -}; -template -class VoidStoredMemberFunctionCall5 : public RunFunctionTask -{ -public: - VoidStoredMemberFunctionCall5(T (Class::*_fn)(Param1, Param2, Param3, Param4, Param5), const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4, const Arg5 &_arg5) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4), arg5(_arg5){ } - - void runFunctor() override - { - (object.*fn)(arg1, arg2, arg3, arg4, arg5); - } -private: - T (Class::*fn)(Param1, Param2, Param3, Param4, Param5); - Class object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; Arg5 arg5; -}; -template -struct SelectStoredMemberFunctionCall5 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredMemberFunctionCall5 >::type type; -}; -template -class StoredConstMemberFunctionCall5 : public RunFunctionTask -{ -public: - StoredConstMemberFunctionCall5(T (Class::*_fn)(Param1, Param2, Param3, Param4, Param5) const, const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4, const Arg5 &_arg5) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4), arg5(_arg5){ } - - void runFunctor() override - { - this->result = (object.*fn)(arg1, arg2, arg3, arg4, arg5); - } -private: - T (Class::*fn)(Param1, Param2, Param3, Param4, Param5) const; - const Class object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; Arg5 arg5; -}; -template -class VoidStoredConstMemberFunctionCall5 : public RunFunctionTask -{ -public: - VoidStoredConstMemberFunctionCall5(T (Class::*_fn)(Param1, Param2, Param3, Param4, Param5) const, const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4, const Arg5 &_arg5) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4), arg5(_arg5){ } - - void runFunctor() override - { - (object.*fn)(arg1, arg2, arg3, arg4, arg5); - } -private: - T (Class::*fn)(Param1, Param2, Param3, Param4, Param5) const; - const Class object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; Arg5 arg5; -}; -template -struct SelectStoredConstMemberFunctionCall5 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredConstMemberFunctionCall5 >::type type; -}; -template -class StoredMemberFunctionPointerCall5 : public RunFunctionTask -{ -public: - StoredMemberFunctionPointerCall5(T (Class::*_fn)(Param1, Param2, Param3, Param4, Param5), Class *_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4, const Arg5 &_arg5) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4), arg5(_arg5){ } - - void runFunctor() override - { - this->result = (object->*fn)(arg1, arg2, arg3, arg4, arg5); - } -private: - T (Class::*fn)(Param1, Param2, Param3, Param4, Param5); - Class *object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; Arg5 arg5; -}; -template -class VoidStoredMemberFunctionPointerCall5 : public RunFunctionTask -{ -public: - VoidStoredMemberFunctionPointerCall5(T (Class::*_fn)(Param1, Param2, Param3, Param4, Param5), Class *_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4, const Arg5 &_arg5) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4), arg5(_arg5){ } - - void runFunctor() override - { - (object->*fn)(arg1, arg2, arg3, arg4, arg5); - } -private: - T (Class::*fn)(Param1, Param2, Param3, Param4, Param5); - Class *object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; Arg5 arg5; -}; -template -struct SelectStoredMemberFunctionPointerCall5 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredMemberFunctionPointerCall5 >::type type; -}; -template -class StoredConstMemberFunctionPointerCall5 : public RunFunctionTask -{ -public: - StoredConstMemberFunctionPointerCall5(T (Class::*_fn)(Param1, Param2, Param3, Param4, Param5) const, Class const *_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4, const Arg5 &_arg5) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4), arg5(_arg5){ } - void runFunctor() override - { - this->result = (object->*fn)(arg1, arg2, arg3, arg4, arg5); - } -private: - T (Class::*fn)(Param1, Param2, Param3, Param4, Param5) const; - Class const *object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; Arg5 arg5; -}; -template -class VoidStoredConstMemberFunctionPointerCall5 : public RunFunctionTask -{ -public: - VoidStoredConstMemberFunctionPointerCall5(T (Class::*_fn)(Param1, Param2, Param3, Param4, Param5) const, Class const *_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4, const Arg5 &_arg5) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4), arg5(_arg5){ } - - void runFunctor() override - { - (object->*fn)(arg1, arg2, arg3, arg4, arg5); - } -private: - T (Class::*fn)(Param1, Param2, Param3, Param4, Param5) const; - Class const *object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; Arg5 arg5; -}; -template -struct SelectStoredConstMemberFunctionPointerCall5 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredConstMemberFunctionPointerCall5 >::type type; -}; -#if defined(__cpp_noexcept_function_type) && __cpp_noexcept_function_type >= 201510 -template -class StoredNoExceptMemberFunctionCall5 : public RunFunctionTask -{ -public: - StoredNoExceptMemberFunctionCall5(T (Class::*_fn)(Param1, Param2, Param3, Param4, Param5) noexcept, const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4, const Arg5 &_arg5) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4), arg5(_arg5){ } - - void runFunctor() override - { - this->result = (object.*fn)(arg1, arg2, arg3, arg4, arg5); - } -private: - T (Class::*fn)(Param1, Param2, Param3, Param4, Param5) noexcept; - Class object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; Arg5 arg5; -}; -template -class VoidStoredNoExceptMemberFunctionCall5 : public RunFunctionTask +template +struct InvokeResult { -public: - VoidStoredNoExceptMemberFunctionCall5(T (Class::*_fn)(Param1, Param2, Param3, Param4, Param5) noexcept, const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4, const Arg5 &_arg5) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4), arg5(_arg5){ } + static_assert(std::is_invocable_v, std::decay_t...>, + "It's not possible to invoke the function with passed arguments."); - void runFunctor() override - { - (object.*fn)(arg1, arg2, arg3, arg4, arg5); - } -private: - T (Class::*fn)(Param1, Param2, Param3, Param4, Param5) noexcept; - Class object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; Arg5 arg5; -}; -template -struct SelectStoredNoExceptMemberFunctionCall5 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredNoExceptMemberFunctionCall5 >::type type; + using Type = std::invoke_result_t, std::decay_t...>; }; -template -class StoredConstNoExceptMemberFunctionCall5 : public RunFunctionTask -{ -public: - StoredConstNoExceptMemberFunctionCall5(T (Class::*_fn)(Param1, Param2, Param3, Param4, Param5) const noexcept, const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4, const Arg5 &_arg5) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4), arg5(_arg5){ } - void runFunctor() override - { - this->result = (object.*fn)(arg1, arg2, arg3, arg4, arg5); - } -private: - T (Class::*fn)(Param1, Param2, Param3, Param4, Param5) const noexcept; - const Class object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; Arg5 arg5; -}; -template -class VoidStoredConstNoExceptMemberFunctionCall5 : public RunFunctionTask -{ -public: - VoidStoredConstNoExceptMemberFunctionCall5(T (Class::*_fn)(Param1, Param2, Param3, Param4, Param5) const noexcept, const Class &_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4, const Arg5 &_arg5) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4), arg5(_arg5){ } +template +using InvokeResultType = typename InvokeResult::Type; - void runFunctor() override - { - (object.*fn)(arg1, arg2, arg3, arg4, arg5); - } -private: - T (Class::*fn)(Param1, Param2, Param3, Param4, Param5) const noexcept; - const Class object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; Arg5 arg5; -}; -template -struct SelectStoredConstNoExceptMemberFunctionCall5 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredConstNoExceptMemberFunctionCall5 >::type type; -}; -template -class StoredNoExceptMemberFunctionPointerCall5 : public RunFunctionTask +template +struct StoredFunctionCall : public RunFunctionTask> { -public: - StoredNoExceptMemberFunctionPointerCall5(T (Class::*_fn)(Param1, Param2, Param3, Param4, Param5) noexcept, Class *_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4, const Arg5 &_arg5) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4), arg5(_arg5){ } + template + using DecayedTuple = std::tuple...>; - void runFunctor() override - { - this->result = (object->*fn)(arg1, arg2, arg3, arg4, arg5); - } -private: - T (Class::*fn)(Param1, Param2, Param3, Param4, Param5) noexcept; - Class *object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; Arg5 arg5; -}; -template -class VoidStoredNoExceptMemberFunctionPointerCall5 : public RunFunctionTask -{ -public: - VoidStoredNoExceptMemberFunctionPointerCall5(T (Class::*_fn)(Param1, Param2, Param3, Param4, Param5) noexcept, Class *_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4, const Arg5 &_arg5) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4), arg5(_arg5){ } + StoredFunctionCall(Function &&f, Args &&...args) + : data{std::forward(f), std::forward(args)...} + {} void runFunctor() override { - (object->*fn)(arg1, arg2, arg3, arg4, arg5); - } -private: - T (Class::*fn)(Param1, Param2, Param3, Param4, Param5) noexcept; - Class *object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; Arg5 arg5; -}; -template -struct SelectStoredNoExceptMemberFunctionPointerCall5 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredNoExceptMemberFunctionPointerCall5 >::type type; -}; -template -class StoredConstNoExceptMemberFunctionPointerCall5 : public RunFunctionTask -{ -public: - StoredConstNoExceptMemberFunctionPointerCall5(T (Class::*_fn)(Param1, Param2, Param3, Param4, Param5) const noexcept, Class const *_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4, const Arg5 &_arg5) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4), arg5(_arg5){ } + using Indexes = + std::make_index_sequence< + std::tuple_size>::value>; - void runFunctor() override - { - this->result = (object->*fn)(arg1, arg2, arg3, arg4, arg5); + invoke(Indexes()); } -private: - T (Class::*fn)(Param1, Param2, Param3, Param4, Param5) const noexcept; - Class const *object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; Arg5 arg5; -}; -template -class VoidStoredConstNoExceptMemberFunctionPointerCall5 : public RunFunctionTask -{ -public: - VoidStoredConstNoExceptMemberFunctionPointerCall5(T (Class::*_fn)(Param1, Param2, Param3, Param4, Param5) const noexcept, Class const *_object, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4, const Arg5 &_arg5) - : fn(_fn), object(_object), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4), arg5(_arg5){ } - void runFunctor() override + template + void invoke(std::index_sequence) { - (object->*fn)(arg1, arg2, arg3, arg4, arg5); + if constexpr (std::is_void_v>) + std::invoke(std::get(std::move(data))...); + else + this->result = std::invoke(std::get(std::move(data))...); } -private: - T (Class::*fn)(Param1, Param2, Param3, Param4, Param5) const noexcept; - Class const *object; - Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; Arg5 arg5; -}; -template -struct SelectStoredConstNoExceptMemberFunctionPointerCall5 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredConstNoExceptMemberFunctionPointerCall5 >::type type; -}; -#endif -template -class StoredFunctorCall : public RunFunctionTask -{ -public: - StoredFunctorCall(const Functor &f) : functor(f) { } - void runFunctor() override - { - this->result = functor(); - } -private: - Functor functor; -}; -template -class StoredFunctorCall : public RunFunctionTask -{ -public: - StoredFunctorCall(const Functor &f) : functor(f) { } - void runFunctor() override - { - functor(); - } -private: - Functor functor; + DecayedTuple data; }; - } //namespace QtConcurrent #endif // Q_QDOC diff --git a/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp b/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp index a4eb2936b5..c0782d8483 100644 --- a/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp +++ b/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp @@ -50,6 +50,7 @@ private slots: #endif void functor(); void lambda(); + void callableObjectWithState(); }; void light() @@ -152,24 +153,24 @@ void tst_QtConcurrentRun::returnValue() QCOMPARE(f.result(), 10); A a; - f = run(&a, &A::member0); + f = run(&A::member0, &a); QCOMPARE(f.result(), 10); - f = run(&pool, &a, &A::member0); + f = run(&pool, &A::member0, &a); QCOMPARE(f.result(), 10); - f = run(&a, &A::member1, 20); + f = run(&A::member1, &a, 20); QCOMPARE(f.result(), 20); - f = run(&pool, &a, &A::member1, 20); + f = run(&pool, &A::member1, &a, 20); QCOMPARE(f.result(), 20); - f = run(a, &A::member0); + f = run(&A::member0, a); QCOMPARE(f.result(), 10); - f = run(&pool, a, &A::member0); + f = run(&pool, &A::member0, a); QCOMPARE(f.result(), 10); - f = run(a, &A::member1, 20); + f = run(&A::member1, a, 20); QCOMPARE(f.result(), 20); - f = run(&pool, a, &A::member1, 20); + f = run(&pool, &A::member1, a, 20); QCOMPARE(f.result(), 20); f = run(a); @@ -177,9 +178,9 @@ void tst_QtConcurrentRun::returnValue() f = run(&pool, a); QCOMPARE(f.result(), 10); - f = run(&a); + f = run(a); QCOMPARE(f.result(), 10); - f = run(&pool, &a); + f = run(&pool, std::ref(a)); QCOMPARE(f.result(), 10); f = run(a, 20); @@ -187,30 +188,30 @@ void tst_QtConcurrentRun::returnValue() f = run(&pool, a, 20); QCOMPARE(f.result(), 20); - f = run(&a, 20); + f = run(std::ref(a), 20); QCOMPARE(f.result(), 20); - f = run(&pool, &a, 20); + f = run(&pool, std::ref(a), 20); QCOMPARE(f.result(), 20); const AConst aConst = AConst(); - f = run(&aConst, &AConst::member0); + f = run(&AConst::member0, &aConst); QCOMPARE(f.result(), 10); - f = run(&pool, &aConst, &AConst::member0); + f = run(&pool, &AConst::member0, &aConst); QCOMPARE(f.result(), 10); - f = run(&aConst, &AConst::member1, 20); + f = run(&AConst::member1, &aConst, 20); QCOMPARE(f.result(), 20); - f = run(&pool, &aConst, &AConst::member1, 20); + f = run(&pool, &AConst::member1, &aConst, 20); QCOMPARE(f.result(), 20); - f = run(aConst, &AConst::member0); + f = run(&AConst::member0, aConst); QCOMPARE(f.result(), 10); - f = run(&pool, aConst, &AConst::member0); + f = run(&pool, &AConst::member0, aConst); QCOMPARE(f.result(), 10); - f = run(aConst, &AConst::member1, 20); + f = run(&AConst::member1, aConst, 20); QCOMPARE(f.result(), 20); - f = run(&pool, aConst, &AConst::member1, 20); + f = run(&pool, &AConst::member1, aConst, 20); QCOMPARE(f.result(), 20); f = run(aConst); @@ -218,9 +219,9 @@ void tst_QtConcurrentRun::returnValue() f = run(&pool, aConst); QCOMPARE(f.result(), 10); - f = run(&aConst); + f = run(std::ref(a)); QCOMPARE(f.result(), 10); - f = run(&pool, &aConst); + f = run(&pool, std::ref(a)); QCOMPARE(f.result(), 10); f = run(aConst, 20); @@ -228,30 +229,30 @@ void tst_QtConcurrentRun::returnValue() f = run(&pool, aConst, 20); QCOMPARE(f.result(), 20); - f = run(&aConst, 20); + f = run(std::ref(aConst), 20); QCOMPARE(f.result(), 20); - f = run(&pool, &aConst, 20); + f = run(&pool, std::ref(aConst), 20); QCOMPARE(f.result(), 20); ANoExcept aNoExcept; - f = run(&aNoExcept, &ANoExcept::member0); + f = run(&ANoExcept::member0, &aNoExcept); QCOMPARE(f.result(), 10); - f = run(&pool, &aNoExcept, &ANoExcept::member0); + f = run(&pool, &ANoExcept::member0, &aNoExcept); QCOMPARE(f.result(), 10); - f = run(&aNoExcept, &ANoExcept::member1, 20); + f = run(&ANoExcept::member1, &aNoExcept, 20); QCOMPARE(f.result(), 20); - f = run(&pool, &aNoExcept, &ANoExcept::member1, 20); + f = run(&pool, &ANoExcept::member1, &aNoExcept, 20); QCOMPARE(f.result(), 20); - f = run(aNoExcept, &ANoExcept::member0); + f = run(&ANoExcept::member0, aNoExcept); QCOMPARE(f.result(), 10); - f = run(&pool, aNoExcept, &ANoExcept::member0); + f = run(&pool, &ANoExcept::member0, aNoExcept); QCOMPARE(f.result(), 10); - f = run(aNoExcept, &ANoExcept::member1, 20); + f = run(&ANoExcept::member1, aNoExcept, 20); QCOMPARE(f.result(), 20); - f = run(&pool, aNoExcept, &ANoExcept::member1, 20); + f = run(&pool, &ANoExcept::member1, aNoExcept, 20); QCOMPARE(f.result(), 20); f = run(aNoExcept); @@ -259,9 +260,9 @@ void tst_QtConcurrentRun::returnValue() f = run(&pool, aNoExcept); QCOMPARE(f.result(), 10); - f = run(&aNoExcept); + f = run(std::ref(aNoExcept)); QCOMPARE(f.result(), 10); - f = run(&pool, &aNoExcept); + f = run(&pool, std::ref(aNoExcept)); QCOMPARE(f.result(), 10); f = run(aNoExcept, 20); @@ -269,30 +270,30 @@ void tst_QtConcurrentRun::returnValue() f = run(&pool, aNoExcept, 20); QCOMPARE(f.result(), 20); - f = run(&aNoExcept, 20); + f = run(std::ref(aNoExcept), 20); QCOMPARE(f.result(), 20); - f = run(&pool, &aNoExcept, 20); + f = run(&pool, std::ref(aNoExcept), 20); QCOMPARE(f.result(), 20); const AConstNoExcept aConstNoExcept = AConstNoExcept(); - f = run(&aConstNoExcept, &AConstNoExcept::member0); + f = run(&AConstNoExcept::member0, &aConstNoExcept); QCOMPARE(f.result(), 10); - f = run(&pool, &aConstNoExcept, &AConstNoExcept::member0); + f = run(&pool, &AConstNoExcept::member0, &aConstNoExcept); QCOMPARE(f.result(), 10); - f = run(&aConstNoExcept, &AConstNoExcept::member1, 20); + f = run(&AConstNoExcept::member1, &aConstNoExcept, 20); QCOMPARE(f.result(), 20); - f = run(&pool, &aConstNoExcept, &AConstNoExcept::member1, 20); + f = run(&pool, &AConstNoExcept::member1, &aConstNoExcept, 20); QCOMPARE(f.result(), 20); - f = run(aConstNoExcept, &AConstNoExcept::member0); + f = run(&AConstNoExcept::member0, aConstNoExcept); QCOMPARE(f.result(), 10); - f = run(&pool, aConstNoExcept, &AConstNoExcept::member0); + f = run(&pool, &AConstNoExcept::member0, aConstNoExcept); QCOMPARE(f.result(), 10); - f = run(aConstNoExcept, &AConstNoExcept::member1, 20); + f = run(&AConstNoExcept::member1, aConstNoExcept, 20); QCOMPARE(f.result(), 20); - f = run(&pool, aConstNoExcept, &AConstNoExcept::member1, 20); + f = run(&pool, &AConstNoExcept::member1, aConstNoExcept, 20); QCOMPARE(f.result(), 20); f = run(aConstNoExcept); @@ -300,9 +301,9 @@ void tst_QtConcurrentRun::returnValue() f = run(&pool, aConstNoExcept); QCOMPARE(f.result(), 10); - f = run(&aConstNoExcept); + f = run(std::ref(aConstNoExcept)); QCOMPARE(f.result(), 10); - f = run(&pool, &aConstNoExcept); + f = run(&pool, std::ref(aConstNoExcept)); QCOMPARE(f.result(), 10); f = run(aConstNoExcept, 20); @@ -310,9 +311,9 @@ void tst_QtConcurrentRun::returnValue() f = run(&pool, aConstNoExcept, 20); QCOMPARE(f.result(), 20); - f = run(&aConstNoExcept, 20); + f = run(std::ref(aConstNoExcept), 20); QCOMPARE(f.result(), 20); - f = run(&pool, &aConstNoExcept, 20); + f = run(&pool, std::ref(aConstNoExcept), 20); QCOMPARE(f.result(), 20); } @@ -341,25 +342,25 @@ void tst_QtConcurrentRun::functionObject() TestClass c; f = run(c); - f = run(&c); + f = run(std::ref(c)); f = run(c, 10); - f = run(&c, 10); + f = run(std::ref(c), 10); f = run(&pool, c); - f = run(&pool, &c); + f = run(&pool, std::ref(c)); f = run(&pool, c, 10); - f = run(&pool, &c, 10); + f = run(&pool, std::ref(c), 10); const TestConstClass cc = TestConstClass(); f = run(cc); - f = run(&cc); + f = run(std::ref(c)); f = run(cc, 10); - f = run(&cc, 10); + f = run(std::ref(c), 10); f = run(&pool, cc); - f = run(&pool, &cc); + f = run(&pool, std::ref(c)); f = run(&pool, cc, 10); - f = run(&pool, &cc, 10); + f = run(&pool, std::ref(c), 10); } @@ -369,26 +370,26 @@ void tst_QtConcurrentRun::memberFunctions() TestClass c; - run(c, &TestClass::foo).waitForFinished(); - run(&c, &TestClass::foo).waitForFinished(); - run(c, &TestClass::fooInt, 10).waitForFinished(); - run(&c, &TestClass::fooInt, 10).waitForFinished(); + run(&TestClass::foo, c).waitForFinished(); + run(&TestClass::foo, &c).waitForFinished(); + run(&TestClass::fooInt, c, 10).waitForFinished(); + run(&TestClass::fooInt, &c, 10).waitForFinished(); - run(&pool, c, &TestClass::foo).waitForFinished(); - run(&pool, &c, &TestClass::foo).waitForFinished(); - run(&pool, c, &TestClass::fooInt, 10).waitForFinished(); - run(&pool, &c, &TestClass::fooInt, 10).waitForFinished(); + run(&pool, &TestClass::foo, c).waitForFinished(); + run(&pool, &TestClass::foo, &c).waitForFinished(); + run(&pool, &TestClass::fooInt, c, 10).waitForFinished(); + run(&pool, &TestClass::fooInt, &c, 10).waitForFinished(); const TestConstClass cc = TestConstClass(); - run(cc, &TestConstClass::foo).waitForFinished(); - run(&cc, &TestConstClass::foo).waitForFinished(); - run(cc, &TestConstClass::fooInt, 10).waitForFinished(); - run(&cc, &TestConstClass::fooInt, 10).waitForFinished(); + run(&TestConstClass::foo, cc).waitForFinished(); + run(&TestConstClass::foo, &cc).waitForFinished(); + run(&TestConstClass::fooInt, cc, 10).waitForFinished(); + run(&TestConstClass::fooInt, &cc, 10).waitForFinished(); - run(&pool, cc, &TestConstClass::foo).waitForFinished(); - run(&pool, &cc, &TestConstClass::foo).waitForFinished(); - run(&pool, cc, &TestConstClass::fooInt, 10).waitForFinished(); - run(&pool, &cc, &TestConstClass::fooInt, 10).waitForFinished(); + run(&pool, &TestConstClass::foo, cc).waitForFinished(); + run(&pool, &TestConstClass::foo, &cc).waitForFinished(); + run(&pool, &TestConstClass::fooInt, cc, 10).waitForFinished(); + run(&pool, &TestConstClass::fooInt, &cc, 10).waitForFinished(); } @@ -437,8 +438,8 @@ void tst_QtConcurrentRun::implicitConvertibleTypes() run(stringConstRefFunction, QLatin1String("Foo")).waitForFinished(); run(&pool, stringConstRefFunction, QLatin1String("Foo")).waitForFinished(); QString string; - run(stringRefFunction, string).waitForFinished(); - run(&pool, stringRefFunction, string).waitForFinished(); + run(stringRefFunction, std::ref(string)).waitForFinished(); + run(&pool, stringRefFunction, std::ref(string)).waitForFinished(); } void fn() { } @@ -732,5 +733,34 @@ void tst_QtConcurrentRun::lambda() } } +struct CallableWithState +{ + void setNewState(int newState) { state = newState; } + int operator()(int newState) { return (state = newState); } + + static constexpr int defaultState() { return 42; } + int state = defaultState(); +}; + +void tst_QtConcurrentRun::callableObjectWithState() +{ + CallableWithState o; + + // Run method setNewState explicitly + run(&CallableWithState::setNewState, &o, CallableWithState::defaultState() + 1).waitForFinished(); + QCOMPARE(o.state, CallableWithState::defaultState() + 1); + + // Run operator()(int) explicitly + run(std::ref(o), CallableWithState::defaultState() + 2).waitForFinished(); + QCOMPARE(o.state, CallableWithState::defaultState() + 2); + + // Run on a copy of object (original object remains unchanged) + run(o, CallableWithState::defaultState() + 3).waitForFinished(); + QCOMPARE(o.state, CallableWithState::defaultState() + 2); + + // Explicitly run on a temporary object + QCOMPARE(run(CallableWithState(), 15).result(), 15); +} + QTEST_MAIN(tst_QtConcurrentRun) #include "tst_qtconcurrentrun.moc" diff --git a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp index 4969e417f4..1d79d0dd1f 100644 --- a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp +++ b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp @@ -163,13 +163,13 @@ void tst_QLockFile::lockOutOtherThread() QVERIFY(lockFile.lock()); // Other thread can't acquire lock - QFuture ret = QtConcurrent::run(tryLockFromThread, fileName); + auto ret = QtConcurrent::run(tryLockFromThread, fileName); QCOMPARE(ret.result(), QLockFile::LockFailedError); lockFile.unlock(); // Now other thread can acquire lock - QFuture ret2 = QtConcurrent::run(tryLockFromThread, fileName); + auto ret2 = QtConcurrent::run(tryLockFromThread, fileName); QCOMPARE(ret2.result(), QLockFile::NoError); } @@ -186,13 +186,13 @@ static QLockFile::LockError lockFromThread(const QString &fileName) void tst_QLockFile::raceWithOtherThread() { const QString fileName = dir.path() + "/raceWithOtherThread"; - QFuture ret = QtConcurrent::run(lockFromThread, fileName); - QFuture ret2 = QtConcurrent::run(lockFromThread, fileName); + auto ret = QtConcurrent::run(lockFromThread, fileName); + auto ret2 = QtConcurrent::run(lockFromThread, fileName); QCOMPARE(ret.result(), QLockFile::NoError); QCOMPARE(ret2.result(), QLockFile::NoError); } -static bool lockFromThread(const QString &fileName, int sleepMs, QSemaphore *semThreadReady, QSemaphore *semMainThreadDone) +static bool lockFromThreadAndWait(const QString &fileName, int sleepMs, QSemaphore *semThreadReady, QSemaphore *semMainThreadDone) { QLockFile lockFile(fileName); if (!lockFile.lock()) { @@ -233,7 +233,7 @@ void tst_QLockFile::waitForLock() QLockFile lockFile(fileName); QSemaphore semThreadReady, semMainThreadDone; // Lock file from a thread - QFuture ret = QtConcurrent::run(lockFromThread, fileName, threadSleepMs, &semThreadReady, &semMainThreadDone); + auto ret = QtConcurrent::run(lockFromThreadAndWait, fileName, threadSleepMs, &semThreadReady, &semMainThreadDone); semThreadReady.acquire(); if (releaseEarly) // let the thread release the lock after threadSleepMs @@ -410,7 +410,7 @@ void tst_QLockFile::staleLockRace() QThreadPool::globalInstance()->setMaxThreadCount(10); QFutureSynchronizer synchronizer; for (int i = 0; i < 8; ++i) - synchronizer.addFuture(QtConcurrent::run(tryStaleLockFromThread, fileName)); + synchronizer.addFuture(QtConcurrent::run(tryStaleLockFromThread, fileName)); synchronizer.waitForFinished(); foreach (const QFuture &future, synchronizer.futures()) QVERIFY2(future.result().isEmpty(), qPrintable(future.result())); diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp index 8d046d5499..31d1de4234 100644 --- a/tests/auto/corelib/io/qurl/tst_qurl.cpp +++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp @@ -4067,7 +4067,7 @@ void tst_QUrl::testThreading() QThreadPool::globalInstance()->setMaxThreadCount(100); QFutureSynchronizer sync; for (int i = 0; i < 100; ++i) - sync.addFuture(QtConcurrent::run(this, &tst_QUrl::testThreadingHelper)); + sync.addFuture(QtConcurrent::run(&tst_QUrl::testThreadingHelper, this)); sync.waitForFinished(); delete s_urlStorage; } diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp index 7e3642752e..3c6da506e2 100644 --- a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp +++ b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp @@ -852,14 +852,14 @@ void tst_QMimeDatabase::fromThreads() QThreadPool tp; tp.setMaxThreadCount(20); // Note that data-based tests cannot be used here (QTest::fetchData asserts). - QtConcurrent::run(&tp, this, &tst_QMimeDatabase::mimeTypeForName); - QtConcurrent::run(&tp, this, &tst_QMimeDatabase::aliases); - QtConcurrent::run(&tp, this, &tst_QMimeDatabase::allMimeTypes); - QtConcurrent::run(&tp, this, &tst_QMimeDatabase::icons); - QtConcurrent::run(&tp, this, &tst_QMimeDatabase::inheritance); - QtConcurrent::run(&tp, this, &tst_QMimeDatabase::knownSuffix); - QtConcurrent::run(&tp, this, &tst_QMimeDatabase::mimeTypeForFileWithContent); - QtConcurrent::run(&tp, this, &tst_QMimeDatabase::allMimeTypes); // a second time + QtConcurrent::run(&tp, &tst_QMimeDatabase::mimeTypeForName, this); + QtConcurrent::run(&tp, &tst_QMimeDatabase::aliases, this); + QtConcurrent::run(&tp, &tst_QMimeDatabase::allMimeTypes, this); + QtConcurrent::run(&tp, &tst_QMimeDatabase::icons, this); + QtConcurrent::run(&tp, &tst_QMimeDatabase::inheritance, this); + QtConcurrent::run(&tp, &tst_QMimeDatabase::knownSuffix, this); + QtConcurrent::run(&tp, &tst_QMimeDatabase::mimeTypeForFileWithContent, this); + QtConcurrent::run(&tp, &tst_QMimeDatabase::allMimeTypes, this); // a second time QVERIFY(tp.waitForDone(60000)); } -- cgit v1.2.3