From 80f21802509ed01a092dc3227f721803e9c4ba18 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 31 Jul 2014 15:46:10 +0200 Subject: [PATCH] qtconcurrent/generaterun: adapt to run(QThreadPool *pool,...) The output is still very different from the checked-in file in QtCore. Change-Id: I02f7489867b891c7867deebd33a39547c16923e4 Reviewed-by: Olivier Goffart --- src/qtconcurrent/generaterun/main.cpp | 48 ++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/src/qtconcurrent/generaterun/main.cpp b/src/qtconcurrent/generaterun/main.cpp index 6108fdc..174a4b1 100644 --- a/src/qtconcurrent/generaterun/main.cpp +++ b/src/qtconcurrent/generaterun/main.cpp @@ -90,80 +90,81 @@ Item Line(Item item) return item + "\n"; } -Item generateRunFunctions(int repeats) +Item generateRunFunctions(int repeats, bool withExplicitPoolArg) { Item functionPointerType = "T (*)(" + parameterTypesNoPrefix + ")"; Item functionPointerParameter = "T (*functionPointer)(" + parameterTypesNoPrefix + ")"; - + const Item pool = withExplicitPoolArg ? "QThreadPool *pool, " : ""; + const char * const startArg = withExplicitPoolArg ? "pool" : ""; // plain functions Repeater functions = Line ("template ") + - Line ("QFuture run(" + functionPointerParameter + functionParameters + ")") + + Line ("QFuture run(" + pool + functionPointerParameter + functionParameters + ")") + Line("{") + Line(" return (new QT_TYPENAME SelectStoredFunctorCall" + Counter() + "::type(functionPointer" + arguments + "))->start();") + + functionPointerType + argumentTypes + ">::type(functionPointer" + arguments + "))->start(" + startArg + ");") + Line("}"); functions.setRepeatCount(repeats); // function objects by value Repeater functionObjects = Line ("template ") + - Line ("QFuture run(FunctionObject functionObject" + functionParameters + ")") + + Line ("QFuture run(" + pool + "FunctionObject functionObject" + functionParameters + ")") + Line("{") + Line(" return (new QT_TYPENAME SelectStoredFunctorCall" + Counter() + "::type(functionObject" + arguments + "))->start();") + + argumentTypes + ">::type(functionObject" + arguments + "))->start(" + startArg + ");") + Line("}"); functionObjects.setRepeatCount(repeats); // function objects by pointer Repeater functionObjectsPointer = Line ("template ") + - Line ("QFuture run(FunctionObject *functionObject" + functionParameters + ")") + + Line ("QFuture run(" + pool + "FunctionObject *functionObject" + functionParameters + ")") + Line("{") + Line(" return (new QT_TYPENAME SelectStoredFunctorPointerCall" + Counter() + "::type(functionObject" + arguments + "))->start();") + + argumentTypes + ">::type(functionObject" + arguments + "))->start(" + startArg + ");") + Line("}"); functionObjectsPointer.setRepeatCount(repeats); // member functions by value Repeater memberFunction = Line ("template ") + - Line ("QFuture run(const Class &object, T (Class::*fn)(" + parameterTypesNoPrefix + ")" + functionParameters + ")") + + Line ("QFuture run(" + pool + "const Class &object, T (Class::*fn)(" + parameterTypesNoPrefix + ")" + functionParameters + ")") + Line("{") + Line(" return (new QT_TYPENAME SelectStoredMemberFunctionCall" + Counter() + "::type(fn, object" + arguments + "))->start();") + + types + ">::type(fn, object" + arguments + "))->start(" + startArg + ");") + Line("}"); memberFunction.setRepeatCount(repeats); // const member functions by value Repeater constMemberFunction = Line ("template ") + - Line ("QFuture run(const Class &object, T (Class::*fn)(" + parameterTypesNoPrefix + ") const" + functionParameters + ")") + + Line ("QFuture run(" + pool + "const Class &object, T (Class::*fn)(" + parameterTypesNoPrefix + ") const" + functionParameters + ")") + Line("{") + Line(" return (new QT_TYPENAME SelectStoredConstMemberFunctionCall" + Counter() + "::type(fn, object" + arguments + "))->start();") + + types + ">::type(fn, object" + arguments + "))->start(" + startArg + ");") + Line("}"); constMemberFunction.setRepeatCount(repeats); // member functions by class pointer Repeater memberFunctionPointer = Line ("template ") + - Line ("QFuture run(Class *object, T (Class::*fn)(" + parameterTypesNoPrefix + ")" + functionParameters + ")") + + Line ("QFuture run(" + pool + "Class *object, T (Class::*fn)(" + parameterTypesNoPrefix + ")" + functionParameters + ")") + Line("{") + Line(" return (new QT_TYPENAME SelectStoredMemberFunctionPointerCall" + Counter() + "::type(fn, object" + arguments + "))->start();") + + types + ">::type(fn, object" + arguments + "))->start(" + startArg + ");") + Line("}"); memberFunctionPointer.setRepeatCount(repeats); // const member functions by class pointer Repeater constMemberFunctionPointer = Line ("template ") + - Line ("QFuture run(const Class *object, T (Class::*fn)(" + parameterTypesNoPrefix + ") const" + functionParameters + ")") + + Line ("QFuture run(" + pool + "const Class *object, T (Class::*fn)(" + parameterTypesNoPrefix + ") const" + functionParameters + ")") + Line("{") + Line(" return (new QT_TYPENAME SelectStoredConstMemberFunctionPointerCall" + Counter() + "::type(fn, object" + arguments + "))->start();") + + types + ">::type(fn, object" + arguments + "))->start(" + startArg + ");") + Line("}"); constMemberFunctionPointer.setRepeatCount(repeats); @@ -173,21 +174,21 @@ Item generateRunFunctions(int repeats) /* // QFutureInterface functions Repeater interfaceFunctions = Line ("template ") + - Line ("QFuture run(" + interfaceFunctionPointerParameter + functionParameters + ")") + + Line ("QFuture run(" + pool + interfaceFunctionPointerParameter + functionParameters + ")") + Line("{") + Line(" return (new StoredInterfaceFunctionCall" + Counter() + "(functionPointer" + arguments + "))->start();") + + interfaceFunctionPointerType + typenameArgumentTypes + ">(functionPointer" + arguments + "))->start(" + startArg + ");") + Line("}"); functions.setRepeatCount(repeats); interfaceFunctions.setRepeatCount(repeats); // member functions by class pointer Repeater interfaceMemberFunction = Line ("template ") + - Line ("QFuture run(void (Class::*fn)(QFutureInterface &), Class *object" + functionParameters + ")") + + Line ("QFuture run(" + pool + "void (Class::*fn)(QFutureInterface &), Class *object" + functionParameters + ")") + Line("{") + Line(" return (new StoredInterfaceMemberFunctionCall" + Counter() + " &), Class" + - typenameArgumentTypes + ">(fn, object" + arguments + "))->start();") + + typenameArgumentTypes + ">(fn, object" + arguments + "))->start(" + startArg + ");") + Line("}"); memberFunctionPointer.setRepeatCount(repeats); */ @@ -364,13 +365,18 @@ int main(int argc, char *argv[]) Line(" template ") + Line(" QFuture run(Function function, ...);") + Line("") + + Line(" template ") + + Line(" QFuture run(QThreadPool *pool, Function function, ...);") + + Line("") + Line("} // namespace QtConcurrent") + Line("") + Line("#else") + Line("") + Line("namespace QtConcurrent {") + Line("") + - generateRunFunctions(repeats) + + generateRunFunctions(repeats, false) + + Line("") + + generateRunFunctions(repeats, true) + Line("} //namespace QtConcurrent") + Line("") + Line("#endif // qdoc") + -- 2.7.4