diff options
author | Christian Kamm <christian.d.kamm@nokia.com> | 2010-03-23 10:57:41 +0100 |
---|---|---|
committer | Christian Kamm <christian.d.kamm@nokia.com> | 2010-03-26 13:05:03 +0100 |
commit | 86153c191a6e0a6228d6d6c705a3e3271a4239be (patch) | |
tree | 42fe7b0eb37e07e15c1de2f5889a026be3b87ea0 | |
parent | 38ba7e1705dca0894f79b9a0de1327ee3cd4c0bf (diff) |
Separate stack creation from construction.
This allows having either a convenient Coroutine-owned stack or
passing in stack memory manually.
-rw-r--r-- | src/coroutine.cpp | 50 | ||||
-rw-r--r-- | src/coroutine.h | 8 | ||||
-rw-r--r-- | src/coroutinebuilddeclaration_p.h | 86 | ||||
-rw-r--r-- | src/coroutinebuilddefinition_p.h | 168 | ||||
-rw-r--r-- | src/coroutinestoredfunctioncall_p.h | 144 | ||||
-rw-r--r-- | tests/auto/basic/tst_basic.cpp | 1 | ||||
-rw-r--r-- | tests/auto/build/tst_build.cpp | 6 | ||||
-rw-r--r-- | tools/generatebuild/main.cpp | 67 |
8 files changed, 269 insertions, 261 deletions
diff --git a/src/coroutine.cpp b/src/coroutine.cpp index 7497765..9c58e2d 100644 --- a/src/coroutine.cpp +++ b/src/coroutine.cpp @@ -12,9 +12,15 @@ thread. New coroutines are made from functions, functors, etc by invoking Coroutine::build - on them. Alternatively, it's possible to derive from Coroutine and overriding + on them. Alternatively, it is possible to derive from Coroutine and overriding the run() method. + After creation it is necessary to set up the coroutine's stack. Call either + createStack() or setStack() to do so. createStack() will make the coroutine allocate + some stack space that it will release on destruction. Using setStack() allows + passing in memory that the coroutine will not take ownership of. The latter + is useful if you have a lot of coroutines and want to reuse their stack memory. + A coroutine doesn't start execution when it is built. Call cont() to run it. This will execute the coroutine's code until it calls Coroutine::yield(). At that point, the call to cont() returns. Subsequent calls to cont() will @@ -28,7 +34,8 @@ qDebug() << "2"; } - Coroutine *c = Coroutine::build(32000, &myCoroutine); + Coroutine *c = Coroutine::build(&myCoroutine); + c->createStack(); qDebug() << "0.5"; c.cont(); // prints 1 qDebug() << "1.5"; @@ -36,7 +43,7 @@ */ /*! - \fn Coroutine *Coroutine::build(int stackSize, Function function, ...) + \fn Coroutine *Coroutine::build(Function function, ...) \brief Creates a new Coroutine from a callable object. The callable object, Function, can be a function pointer, functor or @@ -44,8 +51,7 @@ and member function pointer. In the case of passing functor pointers or object pointers, the Coroutine object doesn't take ownership. - The stackSize value denotes the size of the stack the coroutine will allocate - for execution. + The coroutine will be ready for use after it's stack has been set up. */ @@ -60,7 +66,7 @@ void initializeStack(void *data, int size, void (*entry)(), void **stackPointer) void switchStack(void* to, void** from) { _switchStackInternal(to, from); } #endif -Coroutine::Coroutine(int stackSize) +Coroutine::Coroutine() : _stackData(0) , _stackPointer(0) , _previousCoroutine(0) @@ -68,23 +74,26 @@ Coroutine::Coroutine(int stackSize) { // establish starting coroutine context if necessary currentCoroutine(); - - _stackData = malloc(stackSize); - initializeStack(_stackData, stackSize, &entryPoint, &_stackPointer); } -Coroutine::Coroutine(bool) - : _stackData(0) - , _stackPointer(0) - , _previousCoroutine(0) - , _status(Running) +Coroutine::~Coroutine() { + if (_stackData) + free(_stackData); } -Coroutine::~Coroutine() +void Coroutine::createStack(int size) { if (_stackData) free(_stackData); + + _stackData = malloc(size); + initializeStack(_stackData, size, &entryPoint, &_stackPointer); +} + +void Coroutine::setStack(void *memory, int size) +{ + initializeStack(memory, size, &entryPoint, &_stackPointer); } static QThreadStorage<Coroutine **> qt_currentCoroutine; @@ -93,9 +102,11 @@ Coroutine *Coroutine::currentCoroutine() { // establish a context for the starting coroutine if (!qt_currentCoroutine.hasLocalData()) { - Coroutine *current = new Coroutine(true); - qt_currentCoroutine.setLocalData(new Coroutine*(current)); - return current; + Coroutine **currentPtr = new Coroutine*; + qt_currentCoroutine.setLocalData(currentPtr); + *currentPtr = new Coroutine; + (*currentPtr)->_status = Running; + return *currentPtr; } return *qt_currentCoroutine.localData(); @@ -113,7 +124,8 @@ bool Coroutine::cont() { Q_ASSERT(_status == NotStarted || _status == Stopped); Q_ASSERT(!_previousCoroutine); - + Q_ASSERT(_stackPointer); + _status = Running; _previousCoroutine = *qt_currentCoroutine.localData(); diff --git a/src/coroutine.h b/src/coroutine.h index 3e8269e..08c4108 100644 --- a/src/coroutine.h +++ b/src/coroutine.h @@ -13,8 +13,11 @@ public: }; public: - explicit Coroutine(int stackSize = 32768); + Coroutine(); virtual ~Coroutine(); + + void createStack(int size = 32768); + void setStack(void *memory, int size); bool cont(); static void yield(); @@ -35,9 +38,6 @@ private: // not copyable Coroutine &operator=(const Coroutine &); private: - // for the original coroutine - Coroutine(bool); - static void yieldHelper(Status stopStatus); static void entryPoint(); diff --git a/src/coroutinebuilddeclaration_p.h b/src/coroutinebuilddeclaration_p.h index f44b91a..2a58820 100644 --- a/src/coroutinebuilddeclaration_p.h +++ b/src/coroutinebuilddeclaration_p.h @@ -11,100 +11,100 @@ #ifdef qdoc - static Coroutine* build(int stackSize, Function function, ...); + static Coroutine* build(Function function, ...); #else -static Coroutine* build(int stackSize, void (*functionPointer)()); +static Coroutine* build(void (*functionPointer)()); template <typename Param1, typename Arg1> -static Coroutine* build(int stackSize, void (*functionPointer)(Param1), const Arg1 &arg1); +static Coroutine* build(void (*functionPointer)(Param1), const Arg1 &arg1); template <typename Param1, typename Arg1, typename Param2, typename Arg2> -static Coroutine* build(int stackSize, void (*functionPointer)(Param1, Param2), const Arg1 &arg1, const Arg2 &arg2); +static Coroutine* build(void (*functionPointer)(Param1, Param2), const Arg1 &arg1, const Arg2 &arg2); template <typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3> -static Coroutine* build(int stackSize, void (*functionPointer)(Param1, Param2, Param3), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3); +static Coroutine* build(void (*functionPointer)(Param1, Param2, Param3), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3); template <typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3, typename Param4, typename Arg4> -static Coroutine* build(int stackSize, void (*functionPointer)(Param1, Param2, Param3, Param4), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4); +static Coroutine* build(void (*functionPointer)(Param1, Param2, Param3, Param4), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4); template <typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3, typename Param4, typename Arg4, typename Param5, typename Arg5> -static Coroutine* build(int stackSize, void (*functionPointer)(Param1, Param2, Param3, Param4, Param5), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5); +static Coroutine* build(void (*functionPointer)(Param1, Param2, Param3, Param4, Param5), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5); template <typename FunctionObject> -static Coroutine* build(int stackSize, FunctionObject functionObject); +static Coroutine* build(FunctionObject functionObject); template <typename FunctionObject, typename Arg1> -static Coroutine* build(int stackSize, FunctionObject functionObject, const Arg1 &arg1); +static Coroutine* build(FunctionObject functionObject, const Arg1 &arg1); template <typename FunctionObject, typename Arg1, typename Arg2> -static Coroutine* build(int stackSize, FunctionObject functionObject, const Arg1 &arg1, const Arg2 &arg2); +static Coroutine* build(FunctionObject functionObject, const Arg1 &arg1, const Arg2 &arg2); template <typename FunctionObject, typename Arg1, typename Arg2, typename Arg3> -static Coroutine* build(int stackSize, FunctionObject functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3); +static Coroutine* build(FunctionObject functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3); template <typename FunctionObject, typename Arg1, typename Arg2, typename Arg3, typename Arg4> -static Coroutine* build(int stackSize, FunctionObject functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4); +static Coroutine* build(FunctionObject functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4); template <typename FunctionObject, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5> -static Coroutine* build(int stackSize, FunctionObject functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5); +static Coroutine* build(FunctionObject functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5); template <typename FunctionObject> -static Coroutine* build(int stackSize, FunctionObject *functionObject); +static Coroutine* build(FunctionObject *functionObject); template <typename FunctionObject, typename Arg1> -static Coroutine* build(int stackSize, FunctionObject *functionObject, const Arg1 &arg1); +static Coroutine* build(FunctionObject *functionObject, const Arg1 &arg1); template <typename FunctionObject, typename Arg1, typename Arg2> -static Coroutine* build(int stackSize, FunctionObject *functionObject, const Arg1 &arg1, const Arg2 &arg2); +static Coroutine* build(FunctionObject *functionObject, const Arg1 &arg1, const Arg2 &arg2); template <typename FunctionObject, typename Arg1, typename Arg2, typename Arg3> -static Coroutine* build(int stackSize, FunctionObject *functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3); +static Coroutine* build(FunctionObject *functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3); template <typename FunctionObject, typename Arg1, typename Arg2, typename Arg3, typename Arg4> -static Coroutine* build(int stackSize, FunctionObject *functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4); +static Coroutine* build(FunctionObject *functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4); template <typename FunctionObject, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5> -static Coroutine* build(int stackSize, FunctionObject *functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5); +static Coroutine* build(FunctionObject *functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5); template <typename Class> -static Coroutine* build(int stackSize, const Class &object, void (Class::*fn)()); +static Coroutine* build(const Class &object, void (Class::*fn)()); template <typename Class, typename Param1, typename Arg1> -static Coroutine* build(int stackSize, const Class &object, void (Class::*fn)(Param1), const Arg1 &arg1); +static Coroutine* build(const Class &object, void (Class::*fn)(Param1), const Arg1 &arg1); template <typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2> -static Coroutine* build(int stackSize, const Class &object, void (Class::*fn)(Param1, Param2), const Arg1 &arg1, const Arg2 &arg2); +static Coroutine* build(const Class &object, void (Class::*fn)(Param1, Param2), const Arg1 &arg1, const Arg2 &arg2); template <typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3> -static Coroutine* build(int stackSize, const Class &object, void (Class::*fn)(Param1, Param2, Param3), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3); +static Coroutine* build(const Class &object, void (Class::*fn)(Param1, Param2, Param3), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3); template <typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3, typename Param4, typename Arg4> -static Coroutine* build(int stackSize, const Class &object, void (Class::*fn)(Param1, Param2, Param3, Param4), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4); +static Coroutine* build(const Class &object, void (Class::*fn)(Param1, Param2, Param3, Param4), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4); template <typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3, typename Param4, typename Arg4, typename Param5, typename Arg5> -static Coroutine* build(int stackSize, const Class &object, void (Class::*fn)(Param1, Param2, Param3, Param4, Param5), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5); +static Coroutine* build(const Class &object, void (Class::*fn)(Param1, Param2, Param3, Param4, Param5), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5); template <typename Class> -static Coroutine *build(int stackSize, const Class &object, void (Class::*fn)() const); +static Coroutine* build(const Class &object, void (Class::*fn)() const); template <typename Class, typename Param1, typename Arg1> -static Coroutine *build(int stackSize, const Class &object, void (Class::*fn)(Param1) const, const Arg1 &arg1); +static Coroutine* build(const Class &object, void (Class::*fn)(Param1) const, const Arg1 &arg1); template <typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2> -static Coroutine *build(int stackSize, const Class &object, void (Class::*fn)(Param1, Param2) const, const Arg1 &arg1, const Arg2 &arg2); +static Coroutine* build(const Class &object, void (Class::*fn)(Param1, Param2) const, const Arg1 &arg1, const Arg2 &arg2); template <typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3> -static Coroutine *build(int stackSize, const Class &object, void (Class::*fn)(Param1, Param2, Param3) const, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3); +static Coroutine* build(const Class &object, void (Class::*fn)(Param1, Param2, Param3) const, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3); template <typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3, typename Param4, typename Arg4> -static Coroutine *build(int stackSize, const Class &object, void (Class::*fn)(Param1, Param2, Param3, Param4) const, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4); +static Coroutine* build(const Class &object, void (Class::*fn)(Param1, Param2, Param3, Param4) const, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4); template <typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3, typename Param4, typename Arg4, typename Param5, typename Arg5> -static Coroutine *build(int stackSize, const Class &object, void (Class::*fn)(Param1, Param2, Param3, Param4, Param5) const, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5); +static Coroutine* build(const Class &object, void (Class::*fn)(Param1, Param2, Param3, Param4, Param5) const, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5); template <typename Class> -static Coroutine* build(int stackSize, Class *object, void (Class::*fn)()); +static Coroutine* build(Class *object, void (Class::*fn)()); template <typename Class, typename Param1, typename Arg1> -static Coroutine* build(int stackSize, Class *object, void (Class::*fn)(Param1), const Arg1 &arg1); +static Coroutine* build(Class *object, void (Class::*fn)(Param1), const Arg1 &arg1); template <typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2> -static Coroutine* build(int stackSize, Class *object, void (Class::*fn)(Param1, Param2), const Arg1 &arg1, const Arg2 &arg2); +static Coroutine* build(Class *object, void (Class::*fn)(Param1, Param2), const Arg1 &arg1, const Arg2 &arg2); template <typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3> -static Coroutine* build(int stackSize, Class *object, void (Class::*fn)(Param1, Param2, Param3), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3); +static Coroutine* build(Class *object, void (Class::*fn)(Param1, Param2, Param3), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3); template <typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3, typename Param4, typename Arg4> -static Coroutine* build(int stackSize, Class *object, void (Class::*fn)(Param1, Param2, Param3, Param4), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4); +static Coroutine* build(Class *object, void (Class::*fn)(Param1, Param2, Param3, Param4), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4); template <typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3, typename Param4, typename Arg4, typename Param5, typename Arg5> -static Coroutine* build(int stackSize, Class *object, void (Class::*fn)(Param1, Param2, Param3, Param4, Param5), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5); +static Coroutine* build(Class *object, void (Class::*fn)(Param1, Param2, Param3, Param4, Param5), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5); template <typename Class> -static Coroutine* build(int stackSize, const Class *object, void (Class::*fn)() const); +static Coroutine* build(const Class *object, void (Class::*fn)() const); template <typename Class, typename Param1, typename Arg1> -static Coroutine* build(int stackSize, const Class *object, void (Class::*fn)(Param1) const, const Arg1 &arg1); +static Coroutine* build(const Class *object, void (Class::*fn)(Param1) const, const Arg1 &arg1); template <typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2> -static Coroutine* build(int stackSize, const Class *object, void (Class::*fn)(Param1, Param2) const, const Arg1 &arg1, const Arg2 &arg2); +static Coroutine* build(const Class *object, void (Class::*fn)(Param1, Param2) const, const Arg1 &arg1, const Arg2 &arg2); template <typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3> -static Coroutine* build(int stackSize, const Class *object, void (Class::*fn)(Param1, Param2, Param3) const, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3); +static Coroutine* build(const Class *object, void (Class::*fn)(Param1, Param2, Param3) const, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3); template <typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3, typename Param4, typename Arg4> -static Coroutine* build(int stackSize, const Class *object, void (Class::*fn)(Param1, Param2, Param3, Param4) const, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4); +static Coroutine* build(const Class *object, void (Class::*fn)(Param1, Param2, Param3, Param4) const, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4); template <typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3, typename Param4, typename Arg4, typename Param5, typename Arg5> -static Coroutine* build(int stackSize, const Class *object, void (Class::*fn)(Param1, Param2, Param3, Param4, Param5) const, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5); +static Coroutine* build(const Class *object, void (Class::*fn)(Param1, Param2, Param3, Param4, Param5) const, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5); #endif // qdoc diff --git a/src/coroutinebuilddefinition_p.h b/src/coroutinebuilddefinition_p.h index bf624c1..b97291d 100644 --- a/src/coroutinebuilddefinition_p.h +++ b/src/coroutinebuilddefinition_p.h @@ -14,220 +14,220 @@ #ifndef qdoc -Coroutine* Coroutine::build(int stackSize, void (*functionPointer)()) +Coroutine* Coroutine::build(void (*functionPointer)()) { - return new StoredFunctorCall0<void (*)()>(stackSize, functionPointer); + return new StoredFunctorCall0<void (*)()>(functionPointer); } template <typename Param1, typename Arg1> -Coroutine* Coroutine::build(int stackSize, void (*functionPointer)(Param1), const Arg1 &arg1) +Coroutine* Coroutine::build(void (*functionPointer)(Param1), const Arg1 &arg1) { - return new StoredFunctorCall1<void (*)(Param1), Arg1>(stackSize, functionPointer, arg1); + return new StoredFunctorCall1<void (*)(Param1), Arg1>(functionPointer, arg1); } template <typename Param1, typename Arg1, typename Param2, typename Arg2> -Coroutine* Coroutine::build(int stackSize, void (*functionPointer)(Param1, Param2), const Arg1 &arg1, const Arg2 &arg2) +Coroutine* Coroutine::build(void (*functionPointer)(Param1, Param2), const Arg1 &arg1, const Arg2 &arg2) { - return new StoredFunctorCall2<void (*)(Param1, Param2), Arg1, Arg2>(stackSize, functionPointer, arg1, arg2); + return new StoredFunctorCall2<void (*)(Param1, Param2), Arg1, Arg2>(functionPointer, arg1, arg2); } template <typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3> -Coroutine* Coroutine::build(int stackSize, void (*functionPointer)(Param1, Param2, Param3), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) +Coroutine* Coroutine::build(void (*functionPointer)(Param1, Param2, Param3), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) { - return new StoredFunctorCall3<void (*)(Param1, Param2, Param3), Arg1, Arg2, Arg3>(stackSize, functionPointer, arg1, arg2, arg3); + return new StoredFunctorCall3<void (*)(Param1, Param2, Param3), Arg1, Arg2, Arg3>(functionPointer, arg1, arg2, arg3); } template <typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3, typename Param4, typename Arg4> -Coroutine* Coroutine::build(int stackSize, void (*functionPointer)(Param1, Param2, Param3, Param4), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) +Coroutine* Coroutine::build(void (*functionPointer)(Param1, Param2, Param3, Param4), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) { - return new StoredFunctorCall4<void (*)(Param1, Param2, Param3, Param4), Arg1, Arg2, Arg3, Arg4>(stackSize, functionPointer, arg1, arg2, arg3, arg4); + return new StoredFunctorCall4<void (*)(Param1, Param2, Param3, Param4), Arg1, Arg2, Arg3, Arg4>(functionPointer, arg1, arg2, arg3, arg4); } template <typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3, typename Param4, typename Arg4, typename Param5, typename Arg5> -Coroutine* Coroutine::build(int stackSize, void (*functionPointer)(Param1, Param2, Param3, Param4, Param5), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) +Coroutine* Coroutine::build(void (*functionPointer)(Param1, Param2, Param3, Param4, Param5), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) { - return new StoredFunctorCall5<void (*)(Param1, Param2, Param3, Param4, Param5), Arg1, Arg2, Arg3, Arg4, Arg5>(stackSize, functionPointer, arg1, arg2, arg3, arg4, arg5); + return new StoredFunctorCall5<void (*)(Param1, Param2, Param3, Param4, Param5), Arg1, Arg2, Arg3, Arg4, Arg5>(functionPointer, arg1, arg2, arg3, arg4, arg5); } template <typename FunctionObject> -Coroutine* Coroutine::build(int stackSize, FunctionObject functionObject) +Coroutine* Coroutine::build(FunctionObject functionObject) { - return new StoredFunctorCall0<FunctionObject>(stackSize, functionObject); + return new StoredFunctorCall0<FunctionObject>(functionObject); } template <typename FunctionObject, typename Arg1> -Coroutine* Coroutine::build(int stackSize, FunctionObject functionObject, const Arg1 &arg1) +Coroutine* Coroutine::build(FunctionObject functionObject, const Arg1 &arg1) { - return new StoredFunctorCall1<FunctionObject, Arg1>(stackSize, functionObject, arg1); + return new StoredFunctorCall1<FunctionObject, Arg1>(functionObject, arg1); } template <typename FunctionObject, typename Arg1, typename Arg2> -Coroutine* Coroutine::build(int stackSize, FunctionObject functionObject, const Arg1 &arg1, const Arg2 &arg2) +Coroutine* Coroutine::build(FunctionObject functionObject, const Arg1 &arg1, const Arg2 &arg2) { - return new StoredFunctorCall2<FunctionObject, Arg1, Arg2>(stackSize, functionObject, arg1, arg2); + return new StoredFunctorCall2<FunctionObject, Arg1, Arg2>(functionObject, arg1, arg2); } template <typename FunctionObject, typename Arg1, typename Arg2, typename Arg3> -Coroutine* Coroutine::build(int stackSize, FunctionObject functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) +Coroutine* Coroutine::build(FunctionObject functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) { - return new StoredFunctorCall3<FunctionObject, Arg1, Arg2, Arg3>(stackSize, functionObject, arg1, arg2, arg3); + return new StoredFunctorCall3<FunctionObject, Arg1, Arg2, Arg3>(functionObject, arg1, arg2, arg3); } template <typename FunctionObject, typename Arg1, typename Arg2, typename Arg3, typename Arg4> -Coroutine* Coroutine::build(int stackSize, FunctionObject functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) +Coroutine* Coroutine::build(FunctionObject functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) { - return new StoredFunctorCall4<FunctionObject, Arg1, Arg2, Arg3, Arg4>(stackSize, functionObject, arg1, arg2, arg3, arg4); + return new StoredFunctorCall4<FunctionObject, Arg1, Arg2, Arg3, Arg4>(functionObject, arg1, arg2, arg3, arg4); } template <typename FunctionObject, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5> -Coroutine* Coroutine::build(int stackSize, FunctionObject functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) +Coroutine* Coroutine::build(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>(stackSize, functionObject, arg1, arg2, arg3, arg4, arg5); + return new StoredFunctorCall5<FunctionObject, Arg1, Arg2, Arg3, Arg4, Arg5>(functionObject, arg1, arg2, arg3, arg4, arg5); } template <typename FunctionObject> -Coroutine* Coroutine::build(int stackSize, FunctionObject *functionObject) +Coroutine* Coroutine::build(FunctionObject *functionObject) { - return new StoredFunctorPointerCall0<FunctionObject>(stackSize, functionObject); + return new StoredFunctorPointerCall0<FunctionObject>(functionObject); } template <typename FunctionObject, typename Arg1> -Coroutine* Coroutine::build(int stackSize, FunctionObject *functionObject, const Arg1 &arg1) +Coroutine* Coroutine::build(FunctionObject *functionObject, const Arg1 &arg1) { - return new StoredFunctorPointerCall1<FunctionObject, Arg1>(stackSize, functionObject, arg1); + return new StoredFunctorPointerCall1<FunctionObject, Arg1>(functionObject, arg1); } template <typename FunctionObject, typename Arg1, typename Arg2> -Coroutine* Coroutine::build(int stackSize, FunctionObject *functionObject, const Arg1 &arg1, const Arg2 &arg2) +Coroutine* Coroutine::build(FunctionObject *functionObject, const Arg1 &arg1, const Arg2 &arg2) { - return new StoredFunctorPointerCall2<FunctionObject, Arg1, Arg2>(stackSize, functionObject, arg1, arg2); + return new StoredFunctorPointerCall2<FunctionObject, Arg1, Arg2>(functionObject, arg1, arg2); } template <typename FunctionObject, typename Arg1, typename Arg2, typename Arg3> -Coroutine* Coroutine::build(int stackSize, FunctionObject *functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) +Coroutine* Coroutine::build(FunctionObject *functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) { - return new StoredFunctorPointerCall3<FunctionObject, Arg1, Arg2, Arg3>(stackSize, functionObject, arg1, arg2, arg3); + return new StoredFunctorPointerCall3<FunctionObject, Arg1, Arg2, Arg3>(functionObject, arg1, arg2, arg3); } template <typename FunctionObject, typename Arg1, typename Arg2, typename Arg3, typename Arg4> -Coroutine* Coroutine::build(int stackSize, FunctionObject *functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) +Coroutine* Coroutine::build(FunctionObject *functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) { - return new StoredFunctorPointerCall4<FunctionObject, Arg1, Arg2, Arg3, Arg4>(stackSize, functionObject, arg1, arg2, arg3, arg4); + return new StoredFunctorPointerCall4<FunctionObject, Arg1, Arg2, Arg3, Arg4>(functionObject, arg1, arg2, arg3, arg4); } template <typename FunctionObject, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5> -Coroutine* Coroutine::build(int stackSize, FunctionObject *functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) +Coroutine* Coroutine::build(FunctionObject *functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) { - return new StoredFunctorPointerCall5<FunctionObject, Arg1, Arg2, Arg3, Arg4, Arg5>(stackSize, functionObject, arg1, arg2, arg3, arg4, arg5); + return new StoredFunctorPointerCall5<FunctionObject, Arg1, Arg2, Arg3, Arg4, Arg5>(functionObject, arg1, arg2, arg3, arg4, arg5); } template <typename Class> -Coroutine* Coroutine::build(int stackSize, const Class &object, void (Class::*fn)()) +Coroutine* Coroutine::build(const Class &object, void (Class::*fn)()) { - return new StoredMemberFunctionCall0<Class>(stackSize, fn, object); + return new StoredMemberFunctionCall0<Class>(fn, object); } template <typename Class, typename Param1, typename Arg1> -Coroutine* Coroutine::build(int stackSize, const Class &object, void (Class::*fn)(Param1), const Arg1 &arg1) +Coroutine* Coroutine::build(const Class &object, void (Class::*fn)(Param1), const Arg1 &arg1) { - return new StoredMemberFunctionCall1<Class, Param1, Arg1>(stackSize, fn, object, arg1); + return new StoredMemberFunctionCall1<Class, Param1, Arg1>(fn, object, arg1); } template <typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2> -Coroutine* Coroutine::build(int stackSize, const Class &object, void (Class::*fn)(Param1, Param2), const Arg1 &arg1, const Arg2 &arg2) +Coroutine* Coroutine::build(const Class &object, void (Class::*fn)(Param1, Param2), const Arg1 &arg1, const Arg2 &arg2) { - return new StoredMemberFunctionCall2<Class, Param1, Arg1, Param2, Arg2>(stackSize, fn, object, arg1, arg2); + return new StoredMemberFunctionCall2<Class, Param1, Arg1, Param2, Arg2>(fn, object, arg1, arg2); } template <typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3> -Coroutine* Coroutine::build(int stackSize, const Class &object, void (Class::*fn)(Param1, Param2, Param3), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) +Coroutine* Coroutine::build(const Class &object, void (Class::*fn)(Param1, Param2, Param3), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) { - return new StoredMemberFunctionCall3<Class, Param1, Arg1, Param2, Arg2, Param3, Arg3>(stackSize, fn, object, arg1, arg2, arg3); + return new StoredMemberFunctionCall3<Class, Param1, Arg1, Param2, Arg2, Param3, Arg3>(fn, object, arg1, arg2, arg3); } template <typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3, typename Param4, typename Arg4> -Coroutine* Coroutine::build(int stackSize, const Class &object, void (Class::*fn)(Param1, Param2, Param3, Param4), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) +Coroutine* Coroutine::build(const Class &object, void (Class::*fn)(Param1, Param2, Param3, Param4), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) { - return new StoredMemberFunctionCall4<Class, Param1, Arg1, Param2, Arg2, Param3, Arg3, Param4, Arg4>(stackSize, fn, object, arg1, arg2, arg3, arg4); + return new StoredMemberFunctionCall4<Class, Param1, Arg1, Param2, Arg2, Param3, Arg3, Param4, Arg4>(fn, object, arg1, arg2, arg3, arg4); } template <typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3, typename Param4, typename Arg4, typename Param5, typename Arg5> -Coroutine* Coroutine::build(int stackSize, const Class &object, void (Class::*fn)(Param1, Param2, Param3, Param4, Param5), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) +Coroutine* Coroutine::build(const Class &object, void (Class::*fn)(Param1, Param2, Param3, Param4, Param5), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) { - return new StoredMemberFunctionCall5<Class, Param1, Arg1, Param2, Arg2, Param3, Arg3, Param4, Arg4, Param5, Arg5>(stackSize, fn, object, arg1, arg2, arg3, arg4, arg5); + return new StoredMemberFunctionCall5<Class, Param1, Arg1, Param2, Arg2, Param3, Arg3, Param4, Arg4, Param5, Arg5>(fn, object, arg1, arg2, arg3, arg4, arg5); } template <typename Class> -Coroutine* Coroutine::build(int stackSize, const Class &object, void (Class::*fn)() const) +Coroutine* Coroutine::build(const Class &object, void (Class::*fn)() const) { - return new StoredConstMemberFunctionCall0<Class>(stackSize, fn, object); + return new StoredConstMemberFunctionCall0<Class>(fn, object); } template <typename Class, typename Param1, typename Arg1> -Coroutine* Coroutine::build(int stackSize, const Class &object, void (Class::*fn)(Param1) const, const Arg1 &arg1) +Coroutine* Coroutine::build(const Class &object, void (Class::*fn)(Param1) const, const Arg1 &arg1) { - return new StoredConstMemberFunctionCall1<Class, Param1, Arg1>(stackSize, fn, object, arg1); + return new StoredConstMemberFunctionCall1<Class, Param1, Arg1>(fn, object, arg1); } template <typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2> -Coroutine* Coroutine::build(int stackSize, const Class &object, void (Class::*fn)(Param1, Param2) const, const Arg1 &arg1, const Arg2 &arg2) +Coroutine* Coroutine::build(const Class &object, void (Class::*fn)(Param1, Param2) const, const Arg1 &arg1, const Arg2 &arg2) { - return new StoredConstMemberFunctionCall2<Class, Param1, Arg1, Param2, Arg2>(stackSize, fn, object, arg1, arg2); + return new StoredConstMemberFunctionCall2<Class, Param1, Arg1, Param2, Arg2>(fn, object, arg1, arg2); } template <typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3> -Coroutine* Coroutine::build(int stackSize, const Class &object, void (Class::*fn)(Param1, Param2, Param3) const, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) +Coroutine* Coroutine::build(const Class &object, void (Class::*fn)(Param1, Param2, Param3) const, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) { - return new StoredConstMemberFunctionCall3<Class, Param1, Arg1, Param2, Arg2, Param3, Arg3>(stackSize, fn, object, arg1, arg2, arg3); + return new StoredConstMemberFunctionCall3<Class, Param1, Arg1, Param2, Arg2, Param3, Arg3>(fn, object, arg1, arg2, arg3); } template <typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3, typename Param4, typename Arg4> -Coroutine* Coroutine::build(int stackSize, const Class &object, void (Class::*fn)(Param1, Param2, Param3, Param4) const, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) +Coroutine* Coroutine::build(const Class &object, void (Class::*fn)(Param1, Param2, Param3, Param4) const, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) { - return new StoredConstMemberFunctionCall4<Class, Param1, Arg1, Param2, Arg2, Param3, Arg3, Param4, Arg4>(stackSize, fn, object, arg1, arg2, arg3, arg4); + return new StoredConstMemberFunctionCall4<Class, Param1, Arg1, Param2, Arg2, Param3, Arg3, Param4, Arg4>(fn, object, arg1, arg2, arg3, arg4); } template <typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3, typename Param4, typename Arg4, typename Param5, typename Arg5> -Coroutine* Coroutine::build(int stackSize, const Class &object, void (Class::*fn)(Param1, Param2, Param3, Param4, Param5) const, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) +Coroutine* Coroutine::build(const Class &object, void (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 StoredConstMemberFunctionCall5<Class, Param1, Arg1, Param2, Arg2, Param3, Arg3, Param4, Arg4, Param5, Arg5>(stackSize, fn, object, arg1, arg2, arg3, arg4, arg5); + return new StoredConstMemberFunctionCall5<Class, Param1, Arg1, Param2, Arg2, Param3, Arg3, Param4, Arg4, Param5, Arg5>(fn, object, arg1, arg2, arg3, arg4, arg5); } template <typename Class> -Coroutine* Coroutine::build(int stackSize, Class *object, void (Class::*fn)()) +Coroutine* Coroutine::build(Class *object, void (Class::*fn)()) { - return new StoredMemberFunctionPointerCall0<Class>(stackSize, fn, object); + return new StoredMemberFunctionPointerCall0<Class>(fn, object); } template <typename Class, typename Param1, typename Arg1> -Coroutine* Coroutine::build(int stackSize, Class *object, void (Class::*fn)(Param1), const Arg1 &arg1) +Coroutine* Coroutine::build(Class *object, void (Class::*fn)(Param1), const Arg1 &arg1) { - return new StoredMemberFunctionPointerCall1<Class, Param1, Arg1>(stackSize, fn, object, arg1); + return new StoredMemberFunctionPointerCall1<Class, Param1, Arg1>(fn, object, arg1); } template <typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2> -Coroutine* Coroutine::build(int stackSize, Class *object, void (Class::*fn)(Param1, Param2), const Arg1 &arg1, const Arg2 &arg2) +Coroutine* Coroutine::build(Class *object, void (Class::*fn)(Param1, Param2), const Arg1 &arg1, const Arg2 &arg2) { - return new StoredMemberFunctionPointerCall2<Class, Param1, Arg1, Param2, Arg2>(stackSize, fn, object, arg1, arg2); + return new StoredMemberFunctionPointerCall2<Class, Param1, Arg1, Param2, Arg2>(fn, object, arg1, arg2); } template <typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3> -Coroutine* Coroutine::build(int stackSize, Class *object, void (Class::*fn)(Param1, Param2, Param3), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) +Coroutine* Coroutine::build(Class *object, void (Class::*fn)(Param1, Param2, Param3), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) { - return new StoredMemberFunctionPointerCall3<Class, Param1, Arg1, Param2, Arg2, Param3, Arg3>(stackSize, fn, object, arg1, arg2, arg3); + return new StoredMemberFunctionPointerCall3<Class, Param1, Arg1, Param2, Arg2, Param3, Arg3>(fn, object, arg1, arg2, arg3); } template <typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3, typename Param4, typename Arg4> -Coroutine* Coroutine::build(int stackSize, Class *object, void (Class::*fn)(Param1, Param2, Param3, Param4), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) +Coroutine* Coroutine::build(Class *object, void (Class::*fn)(Param1, Param2, Param3, Param4), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) { - return new StoredMemberFunctionPointerCall4<Class, Param1, Arg1, Param2, Arg2, Param3, Arg3, Param4, Arg4>(stackSize, fn, object, arg1, arg2, arg3, arg4); + return new StoredMemberFunctionPointerCall4<Class, Param1, Arg1, Param2, Arg2, Param3, Arg3, Param4, Arg4>(fn, object, arg1, arg2, arg3, arg4); } template <typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3, typename Param4, typename Arg4, typename Param5, typename Arg5> -Coroutine* Coroutine::build(int stackSize, Class *object, void (Class::*fn)(Param1, Param2, Param3, Param4, Param5), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) +Coroutine* Coroutine::build(Class *object, void (Class::*fn)(Param1, Param2, Param3, Param4, Param5), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) { - return new StoredMemberFunctionPointerCall5<Class, Param1, Arg1, Param2, Arg2, Param3, Arg3, Param4, Arg4, Param5, Arg5>(stackSize, fn, object, arg1, arg2, arg3, arg4, arg5); + return new StoredMemberFunctionPointerCall5<Class, Param1, Arg1, Param2, Arg2, Param3, Arg3, Param4, Arg4, Param5, Arg5>(fn, object, arg1, arg2, arg3, arg4, arg5); } template <typename Class> -Coroutine* Coroutine::build(int stackSize, const Class *object, void (Class::*fn)() const) +Coroutine* Coroutine::build(const Class *object, void (Class::*fn)() const) { - return new StoredConstMemberFunctionPointerCall0<Class>(stackSize, fn, object); + return new StoredConstMemberFunctionPointerCall0<Class>(fn, object); } template <typename Class, typename Param1, typename Arg1> -Coroutine* Coroutine::build(int stackSize, const Class *object, void (Class::*fn)(Param1) const, const Arg1 &arg1) +Coroutine* Coroutine::build(const Class *object, void (Class::*fn)(Param1) const, const Arg1 &arg1) { - return new StoredConstMemberFunctionPointerCall1<Class, Param1, Arg1>(stackSize, fn, object, arg1); + return new StoredConstMemberFunctionPointerCall1<Class, Param1, Arg1>(fn, object, arg1); } template <typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2> -Coroutine* Coroutine::build(int stackSize, const Class *object, void (Class::*fn)(Param1, Param2) const, const Arg1 &arg1, const Arg2 &arg2) +Coroutine* Coroutine::build(const Class *object, void (Class::*fn)(Param1, Param2) const, const Arg1 &arg1, const Arg2 &arg2) { - return new StoredConstMemberFunctionPointerCall2<Class, Param1, Arg1, Param2, Arg2>(stackSize, fn, object, arg1, arg2); + return new StoredConstMemberFunctionPointerCall2<Class, Param1, Arg1, Param2, Arg2>(fn, object, arg1, arg2); } template <typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3> -Coroutine* Coroutine::build(int stackSize, const Class *object, void (Class::*fn)(Param1, Param2, Param3) const, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) +Coroutine* Coroutine::build(const Class *object, void (Class::*fn)(Param1, Param2, Param3) const, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) { - return new StoredConstMemberFunctionPointerCall3<Class, Param1, Arg1, Param2, Arg2, Param3, Arg3>(stackSize, fn, object, arg1, arg2, arg3); + return new StoredConstMemberFunctionPointerCall3<Class, Param1, Arg1, Param2, Arg2, Param3, Arg3>(fn, object, arg1, arg2, arg3); } template <typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3, typename Param4, typename Arg4> -Coroutine* Coroutine::build(int stackSize, const Class *object, void (Class::*fn)(Param1, Param2, Param3, Param4) const, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) +Coroutine* Coroutine::build(const Class *object, void (Class::*fn)(Param1, Param2, Param3, Param4) const, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) { - return new StoredConstMemberFunctionPointerCall4<Class, Param1, Arg1, Param2, Arg2, Param3, Arg3, Param4, Arg4>(stackSize, fn, object, arg1, arg2, arg3, arg4); + return new StoredConstMemberFunctionPointerCall4<Class, Param1, Arg1, Param2, Arg2, Param3, Arg3, Param4, Arg4>(fn, object, arg1, arg2, arg3, arg4); } template <typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3, typename Param4, typename Arg4, typename Param5, typename Arg5> -Coroutine* Coroutine::build(int stackSize, const Class *object, void (Class::*fn)(Param1, Param2, Param3, Param4, Param5) const, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) +Coroutine* Coroutine::build(const Class *object, void (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 StoredConstMemberFunctionPointerCall5<Class, Param1, Arg1, Param2, Arg2, Param3, Arg3, Param4, Arg4, Param5, Arg5>(stackSize, fn, object, arg1, arg2, arg3, arg4, arg5); + return new StoredConstMemberFunctionPointerCall5<Class, Param1, Arg1, Param2, Arg2, Param3, Arg3, Param4, Arg4, Param5, Arg5>(fn, object, arg1, arg2, arg3, arg4, arg5); } diff --git a/src/coroutinestoredfunctioncall_p.h b/src/coroutinestoredfunctioncall_p.h index 73e7ddb..bf55271 100644 --- a/src/coroutinestoredfunctioncall_p.h +++ b/src/coroutinestoredfunctioncall_p.h @@ -16,8 +16,8 @@ template <typename FunctionPointer> struct StoredFunctorCall0: public Coroutine { - inline StoredFunctorCall0(int stackSize, FunctionPointer function) - : Coroutine(stackSize), function(function) {} + inline StoredFunctorCall0(FunctionPointer function) + : function(function) {} protected: virtual void run() { function(); } FunctionPointer function; @@ -27,8 +27,8 @@ protected: template <typename FunctionPointer> struct StoredFunctorPointerCall0: public Coroutine { - inline StoredFunctorPointerCall0(int stackSize, FunctionPointer * function) - : Coroutine(stackSize), function(function) {} + inline StoredFunctorPointerCall0(FunctionPointer * function) + : function(function) {} protected: virtual void run() { (*function)(); } FunctionPointer * function; @@ -39,8 +39,8 @@ template <typename Class> class StoredMemberFunctionCall0 : public Coroutine { public: - StoredMemberFunctionCall0(int stackSize, void (Class::*fn)() , const Class &object) - : Coroutine(stackSize), fn(fn), object(object){ } + StoredMemberFunctionCall0(void (Class::*fn)() , const Class &object) + : fn(fn), object(object){ } protected: virtual void run() { @@ -55,8 +55,8 @@ template <typename Class> class StoredConstMemberFunctionCall0 : public Coroutine { public: - StoredConstMemberFunctionCall0(int stackSize, void (Class::*fn)() const, const Class &object) - : Coroutine(stackSize), fn(fn), object(object){ } + StoredConstMemberFunctionCall0(void (Class::*fn)() const, const Class &object) + : fn(fn), object(object){ } protected: virtual void run() { @@ -71,8 +71,8 @@ template <typename Class> class StoredMemberFunctionPointerCall0 : public Coroutine { public: - StoredMemberFunctionPointerCall0(int stackSize, void (Class::*fn)() , Class *object) - : Coroutine(stackSize), fn(fn), object(object){ } + StoredMemberFunctionPointerCall0(void (Class::*fn)() , Class *object) + : fn(fn), object(object){ } protected: virtual void run() { @@ -87,8 +87,8 @@ template <typename Class> class StoredConstMemberFunctionPointerCall0 : public Coroutine { public: - StoredConstMemberFunctionPointerCall0(int stackSize, void (Class::*fn)() const, Class const *object) - : Coroutine(stackSize), fn(fn), object(object){ } + StoredConstMemberFunctionPointerCall0(void (Class::*fn)() const, Class const *object) + : fn(fn), object(object){ } protected: virtual void run() { @@ -102,8 +102,8 @@ private: template <typename FunctionPointer, typename Arg1> struct StoredFunctorCall1: public Coroutine { - inline StoredFunctorCall1(int stackSize, FunctionPointer function, const Arg1 &arg1) - : Coroutine(stackSize), function(function), arg1(arg1) {} + inline StoredFunctorCall1(FunctionPointer function, const Arg1 &arg1) + : function(function), arg1(arg1) {} protected: virtual void run() { function(arg1); } FunctionPointer function; @@ -113,8 +113,8 @@ protected: template <typename FunctionPointer, typename Arg1> struct StoredFunctorPointerCall1: public Coroutine { - inline StoredFunctorPointerCall1(int stackSize, FunctionPointer * function, const Arg1 &arg1) - : Coroutine(stackSize), function(function), arg1(arg1) {} + inline StoredFunctorPointerCall1(FunctionPointer * function, const Arg1 &arg1) + : function(function), arg1(arg1) {} protected: virtual void run() { (*function)(arg1); } FunctionPointer * function; @@ -125,8 +125,8 @@ template <typename Class, typename Param1, typename Arg1> class StoredMemberFunctionCall1 : public Coroutine { public: - StoredMemberFunctionCall1(int stackSize, void (Class::*fn)(Param1) , const Class &object, const Arg1 &arg1) - : Coroutine(stackSize), fn(fn), object(object), arg1(arg1){ } + StoredMemberFunctionCall1(void (Class::*fn)(Param1) , const Class &object, const Arg1 &arg1) + : fn(fn), object(object), arg1(arg1){ } protected: virtual void run() { @@ -141,8 +141,8 @@ template <typename Class, typename Param1, typename Arg1> class StoredConstMemberFunctionCall1 : public Coroutine { public: - StoredConstMemberFunctionCall1(int stackSize, void (Class::*fn)(Param1) const, const Class &object, const Arg1 &arg1) - : Coroutine(stackSize), fn(fn), object(object), arg1(arg1){ } + StoredConstMemberFunctionCall1(void (Class::*fn)(Param1) const, const Class &object, const Arg1 &arg1) + : fn(fn), object(object), arg1(arg1){ } protected: virtual void run() { @@ -157,8 +157,8 @@ template <typename Class, typename Param1, typename Arg1> class StoredMemberFunctionPointerCall1 : public Coroutine { public: - StoredMemberFunctionPointerCall1(int stackSize, void (Class::*fn)(Param1) , Class *object, const Arg1 &arg1) - : Coroutine(stackSize), fn(fn), object(object), arg1(arg1){ } + StoredMemberFunctionPointerCall1(void (Class::*fn)(Param1) , Class *object, const Arg1 &arg1) + : fn(fn), object(object), arg1(arg1){ } protected: virtual void run() { @@ -173,8 +173,8 @@ template <typename Class, typename Param1, typename Arg1> class StoredConstMemberFunctionPointerCall1 : public Coroutine { public: - StoredConstMemberFunctionPointerCall1(int stackSize, void (Class::*fn)(Param1) const, Class const *object, const Arg1 &arg1) - : Coroutine(stackSize), fn(fn), object(object), arg1(arg1){ } + StoredConstMemberFunctionPointerCall1(void (Class::*fn)(Param1) const, Class const *object, const Arg1 &arg1) + : fn(fn), object(object), arg1(arg1){ } protected: virtual void run() { @@ -188,8 +188,8 @@ private: template <typename FunctionPointer, typename Arg1, typename Arg2> struct StoredFunctorCall2: public Coroutine { - inline StoredFunctorCall2(int stackSize, FunctionPointer function, const Arg1 &arg1, const Arg2 &arg2) - : Coroutine(stackSize), function(function), arg1(arg1), arg2(arg2) {} + inline StoredFunctorCall2(FunctionPointer function, const Arg1 &arg1, const Arg2 &arg2) + : function(function), arg1(arg1), arg2(arg2) {} protected: virtual void run() { function(arg1, arg2); } FunctionPointer function; @@ -199,8 +199,8 @@ protected: template <typename FunctionPointer, typename Arg1, typename Arg2> struct StoredFunctorPointerCall2: public Coroutine { - inline StoredFunctorPointerCall2(int stackSize, FunctionPointer * function, const Arg1 &arg1, const Arg2 &arg2) - : Coroutine(stackSize), function(function), arg1(arg1), arg2(arg2) {} + inline StoredFunctorPointerCall2(FunctionPointer * function, const Arg1 &arg1, const Arg2 &arg2) + : function(function), arg1(arg1), arg2(arg2) {} protected: virtual void run() { (*function)(arg1, arg2); } FunctionPointer * function; @@ -211,8 +211,8 @@ template <typename Class, typename Param1, typename Arg1, typename Param2, typen class StoredMemberFunctionCall2 : public Coroutine { public: - StoredMemberFunctionCall2(int stackSize, void (Class::*fn)(Param1, Param2) , const Class &object, const Arg1 &arg1, const Arg2 &arg2) - : Coroutine(stackSize), fn(fn), object(object), arg1(arg1), arg2(arg2){ } + StoredMemberFunctionCall2(void (Class::*fn)(Param1, Param2) , const Class &object, const Arg1 &arg1, const Arg2 &arg2) + : fn(fn), object(object), arg1(arg1), arg2(arg2){ } protected: virtual void run() { @@ -227,8 +227,8 @@ template <typename Class, typename Param1, typename Arg1, typename Param2, typen class StoredConstMemberFunctionCall2 : public Coroutine { public: - StoredConstMemberFunctionCall2(int stackSize, void (Class::*fn)(Param1, Param2) const, const Class &object, const Arg1 &arg1, const Arg2 &arg2) - : Coroutine(stackSize), fn(fn), object(object), arg1(arg1), arg2(arg2){ } + StoredConstMemberFunctionCall2(void (Class::*fn)(Param1, Param2) const, const Class &object, const Arg1 &arg1, const Arg2 &arg2) + : fn(fn), object(object), arg1(arg1), arg2(arg2){ } protected: virtual void run() { @@ -243,8 +243,8 @@ template <typename Class, typename Param1, typename Arg1, typename Param2, typen class StoredMemberFunctionPointerCall2 : public Coroutine { public: - StoredMemberFunctionPointerCall2(int stackSize, void (Class::*fn)(Param1, Param2) , Class *object, const Arg1 &arg1, const Arg2 &arg2) - : Coroutine(stackSize), fn(fn), object(object), arg1(arg1), arg2(arg2){ } + StoredMemberFunctionPointerCall2(void (Class::*fn)(Param1, Param2) , Class *object, const Arg1 &arg1, const Arg2 &arg2) + : fn(fn), object(object), arg1(arg1), arg2(arg2){ } protected: virtual void run() { @@ -259,8 +259,8 @@ template <typename Class, typename Param1, typename Arg1, typename Param2, typen class StoredConstMemberFunctionPointerCall2 : public Coroutine { public: - StoredConstMemberFunctionPointerCall2(int stackSize, void (Class::*fn)(Param1, Param2) const, Class const *object, const Arg1 &arg1, const Arg2 &arg2) - : Coroutine(stackSize), fn(fn), object(object), arg1(arg1), arg2(arg2){ } + StoredConstMemberFunctionPointerCall2(void (Class::*fn)(Param1, Param2) const, Class const *object, const Arg1 &arg1, const Arg2 &arg2) + : fn(fn), object(object), arg1(arg1), arg2(arg2){ } protected: virtual void run() { @@ -274,8 +274,8 @@ private: template <typename FunctionPointer, typename Arg1, typename Arg2, typename Arg3> struct StoredFunctorCall3: public Coroutine { - inline StoredFunctorCall3(int stackSize, FunctionPointer function, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) - : Coroutine(stackSize), function(function), arg1(arg1), arg2(arg2), arg3(arg3) {} + inline StoredFunctorCall3(FunctionPointer function, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) + : function(function), arg1(arg1), arg2(arg2), arg3(arg3) {} protected: virtual void run() { function(arg1, arg2, arg3); } FunctionPointer function; @@ -285,8 +285,8 @@ protected: template <typename FunctionPointer, typename Arg1, typename Arg2, typename Arg3> struct StoredFunctorPointerCall3: public Coroutine { - inline StoredFunctorPointerCall3(int stackSize, FunctionPointer * function, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) - : Coroutine(stackSize), function(function), arg1(arg1), arg2(arg2), arg3(arg3) {} + inline StoredFunctorPointerCall3(FunctionPointer * function, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) + : function(function), arg1(arg1), arg2(arg2), arg3(arg3) {} protected: virtual void run() { (*function)(arg1, arg2, arg3); } FunctionPointer * function; @@ -297,8 +297,8 @@ template <typename Class, typename Param1, typename Arg1, typename Param2, typen class StoredMemberFunctionCall3 : public Coroutine { public: - StoredMemberFunctionCall3(int stackSize, void (Class::*fn)(Param1, Param2, Param3) , const Class &object, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) - : Coroutine(stackSize), fn(fn), object(object), arg1(arg1), arg2(arg2), arg3(arg3){ } + StoredMemberFunctionCall3(void (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){ } protected: virtual void run() { @@ -313,8 +313,8 @@ template <typename Class, typename Param1, typename Arg1, typename Param2, typen class StoredConstMemberFunctionCall3 : public Coroutine { public: - StoredConstMemberFunctionCall3(int stackSize, void (Class::*fn)(Param1, Param2, Param3) const, const Class &object, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) - : Coroutine(stackSize), fn(fn), object(object), arg1(arg1), arg2(arg2), arg3(arg3){ } + StoredConstMemberFunctionCall3(void (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){ } protected: virtual void run() { @@ -329,8 +329,8 @@ template <typename Class, typename Param1, typename Arg1, typename Param2, typen class StoredMemberFunctionPointerCall3 : public Coroutine { public: - StoredMemberFunctionPointerCall3(int stackSize, void (Class::*fn)(Param1, Param2, Param3) , Class *object, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) - : Coroutine(stackSize), fn(fn), object(object), arg1(arg1), arg2(arg2), arg3(arg3){ } + StoredMemberFunctionPointerCall3(void (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){ } protected: virtual void run() { @@ -345,8 +345,8 @@ template <typename Class, typename Param1, typename Arg1, typename Param2, typen class StoredConstMemberFunctionPointerCall3 : public Coroutine { public: - StoredConstMemberFunctionPointerCall3(int stackSize, void (Class::*fn)(Param1, Param2, Param3) const, Class const *object, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) - : Coroutine(stackSize), fn(fn), object(object), arg1(arg1), arg2(arg2), arg3(arg3){ } + StoredConstMemberFunctionPointerCall3(void (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){ } protected: virtual void run() { @@ -360,8 +360,8 @@ private: template <typename FunctionPointer, typename Arg1, typename Arg2, typename Arg3, typename Arg4> struct StoredFunctorCall4: public Coroutine { - inline StoredFunctorCall4(int stackSize, FunctionPointer function, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) - : Coroutine(stackSize), function(function), arg1(arg1), arg2(arg2), arg3(arg3), arg4(arg4) {} + 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) {} protected: virtual void run() { function(arg1, arg2, arg3, arg4); } FunctionPointer function; @@ -371,8 +371,8 @@ protected: template <typename FunctionPointer, typename Arg1, typename Arg2, typename Arg3, typename Arg4> struct StoredFunctorPointerCall4: public Coroutine { - inline StoredFunctorPointerCall4(int stackSize, FunctionPointer * function, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) - : Coroutine(stackSize), function(function), arg1(arg1), arg2(arg2), arg3(arg3), arg4(arg4) {} + 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) {} protected: virtual void run() { (*function)(arg1, arg2, arg3, arg4); } FunctionPointer * function; @@ -383,8 +383,8 @@ template <typename Class, typename Param1, typename Arg1, typename Param2, typen class StoredMemberFunctionCall4 : public Coroutine { public: - StoredMemberFunctionCall4(int stackSize, void (Class::*fn)(Param1, Param2, Param3, Param4) , const Class &object, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) - : Coroutine(stackSize), fn(fn), object(object), arg1(arg1), arg2(arg2), arg3(arg3), arg4(arg4){ } + StoredMemberFunctionCall4(void (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){ } protected: virtual void run() { @@ -399,8 +399,8 @@ template <typename Class, typename Param1, typename Arg1, typename Param2, typen class StoredConstMemberFunctionCall4 : public Coroutine { public: - StoredConstMemberFunctionCall4(int stackSize, void (Class::*fn)(Param1, Param2, Param3, Param4) const, const Class &object, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) - : Coroutine(stackSize), fn(fn), object(object), arg1(arg1), arg2(arg2), arg3(arg3), arg4(arg4){ } + StoredConstMemberFunctionCall4(void (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){ } protected: virtual void run() { @@ -415,8 +415,8 @@ template <typename Class, typename Param1, typename Arg1, typename Param2, typen class StoredMemberFunctionPointerCall4 : public Coroutine { public: - StoredMemberFunctionPointerCall4(int stackSize, void (Class::*fn)(Param1, Param2, Param3, Param4) , Class *object, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) - : Coroutine(stackSize), fn(fn), object(object), arg1(arg1), arg2(arg2), arg3(arg3), arg4(arg4){ } + StoredMemberFunctionPointerCall4(void (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){ } protected: virtual void run() { @@ -431,8 +431,8 @@ template <typename Class, typename Param1, typename Arg1, typename Param2, typen class StoredConstMemberFunctionPointerCall4 : public Coroutine { public: - StoredConstMemberFunctionPointerCall4(int stackSize, void (Class::*fn)(Param1, Param2, Param3, Param4) const, Class const *object, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) - : Coroutine(stackSize), fn(fn), object(object), arg1(arg1), arg2(arg2), arg3(arg3), arg4(arg4){ } + StoredConstMemberFunctionPointerCall4(void (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){ } protected: virtual void run() { @@ -446,8 +446,8 @@ private: template <typename FunctionPointer, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5> struct StoredFunctorCall5: public Coroutine { - inline StoredFunctorCall5(int stackSize, FunctionPointer function, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) - : Coroutine(stackSize), function(function), arg1(arg1), arg2(arg2), arg3(arg3), arg4(arg4), arg5(arg5) {} + 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) {} protected: virtual void run() { function(arg1, arg2, arg3, arg4, arg5); } FunctionPointer function; @@ -457,8 +457,8 @@ protected: template <typename FunctionPointer, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5> struct StoredFunctorPointerCall5: public Coroutine { - inline StoredFunctorPointerCall5(int stackSize, FunctionPointer * function, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) - : Coroutine(stackSize), function(function), arg1(arg1), arg2(arg2), arg3(arg3), arg4(arg4), arg5(arg5) {} + 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) {} protected: virtual void run() { (*function)(arg1, arg2, arg3, arg4, arg5); } FunctionPointer * function; @@ -469,8 +469,8 @@ template <typename Class, typename Param1, typename Arg1, typename Param2, typen class StoredMemberFunctionCall5 : public Coroutine { public: - StoredMemberFunctionCall5(int stackSize, void (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) - : Coroutine(stackSize), fn(fn), object(object), arg1(arg1), arg2(arg2), arg3(arg3), arg4(arg4), arg5(arg5){ } + StoredMemberFunctionCall5(void (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){ } protected: virtual void run() { @@ -485,8 +485,8 @@ template <typename Class, typename Param1, typename Arg1, typename Param2, typen class StoredConstMemberFunctionCall5 : public Coroutine { public: - StoredConstMemberFunctionCall5(int stackSize, void (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) - : Coroutine(stackSize), fn(fn), object(object), arg1(arg1), arg2(arg2), arg3(arg3), arg4(arg4), arg5(arg5){ } + StoredConstMemberFunctionCall5(void (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){ } protected: virtual void run() { @@ -501,8 +501,8 @@ template <typename Class, typename Param1, typename Arg1, typename Param2, typen class StoredMemberFunctionPointerCall5 : public Coroutine { public: - StoredMemberFunctionPointerCall5(int stackSize, void (Class::*fn)(Param1, Param2, Param3, Param4, Param5) , Class *object, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) - : Coroutine(stackSize), fn(fn), object(object), arg1(arg1), arg2(arg2), arg3(arg3), arg4(arg4), arg5(arg5){ } + StoredMemberFunctionPointerCall5(void (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){ } protected: virtual void run() { @@ -517,8 +517,8 @@ template <typename Class, typename Param1, typename Arg1, typename Param2, typen class StoredConstMemberFunctionPointerCall5 : public Coroutine { public: - StoredConstMemberFunctionPointerCall5(int stackSize, void (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) - : Coroutine(stackSize), fn(fn), object(object), arg1(arg1), arg2(arg2), arg3(arg3), arg4(arg4), arg5(arg5){ } + StoredConstMemberFunctionPointerCall5(void (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){ } protected: virtual void run() { diff --git a/tests/auto/basic/tst_basic.cpp b/tests/auto/basic/tst_basic.cpp index c33ef40..8ac7958 100644 --- a/tests/auto/basic/tst_basic.cpp +++ b/tests/auto/basic/tst_basic.cpp @@ -25,6 +25,7 @@ public: void tst_basic::noYield() { NoYieldCoro coro; + coro.createStack(); coro.i = 0; QCOMPARE(coro.status(), Coroutine::NotStarted); QCOMPARE(coro.cont(), false); diff --git a/tests/auto/build/tst_build.cpp b/tests/auto/build/tst_build.cpp index 2574f61..3b94169 100644 --- a/tests/auto/build/tst_build.cpp +++ b/tests/auto/build/tst_build.cpp @@ -32,7 +32,8 @@ static void fnArg(int start) void tst_build::staticFn() { - Coroutine* c1 = Coroutine::build(32000, &fnNoArg); + Coroutine* c1 = Coroutine::build(&fnNoArg); + c1->createStack(); QCOMPARE(fnCounter, -99); QCOMPARE(c1->cont(), true); QCOMPARE(fnCounter, 0); @@ -42,7 +43,8 @@ void tst_build::staticFn() QCOMPARE(fnCounter, 2); delete c1; - Coroutine* c2 = Coroutine::build(32000, &fnArg, 40); + Coroutine* c2 = Coroutine::build(&fnArg, 40); + c2->createStack(); QCOMPARE(c2->cont(), true); QCOMPARE(fnCounter, 40); QCOMPARE(c2->cont(), true); diff --git a/tools/generatebuild/main.cpp b/tools/generatebuild/main.cpp index fd0c496..a2c9036 100644 --- a/tools/generatebuild/main.cpp +++ b/tools/generatebuild/main.cpp @@ -95,82 +95,78 @@ Item Line(Item item) Item generateBuildFunctionDefinitions(int repeats) { - Item nameReturn = "Coroutine* Coroutine::build("; - Item functionPointerType = "void (*)(" + parameterTypesNoPrefix + ")"; + Item nameReturn = "Coroutine* Coroutine::build"; + Item functionPointerType = "void (*)(" + parameterTypesNoPrefix + ")"; Item functionPointerParameter = "void (*functionPointer)(" + parameterTypesNoPrefix + ")"; - Item stackSizeParameter = "int stackSize, "; - Item stackSizeArgument = "stackSize, "; - - // plain functions Repeater functions = Line (typenameTypesWithTemplate) + - Line (nameReturn + stackSizeParameter + functionPointerParameter + functionParameters + ")") + + Line (nameReturn + "(" + functionPointerParameter + functionParameters + ")") + Line("{") + Line(" return new StoredFunctorCall" + Counter() + "<" + - functionPointerType + argumentTypes + ">(" + stackSizeArgument + "functionPointer" + arguments + ");") + + functionPointerType + argumentTypes + ">(functionPointer" + arguments + ");") + Line("}"); functions.setRepeatCount(repeats); // function objects by value Repeater functionObjects = Line ("template <typename FunctionObject" + typenameArgumentTypes + ">") + - Line (nameReturn + stackSizeParameter + "FunctionObject functionObject" + functionParameters + ")") + + Line (nameReturn + "(" + "FunctionObject functionObject" + functionParameters + ")") + Line("{") + Line(" return new StoredFunctorCall" + Counter() + "<FunctionObject" + - argumentTypes + ">(" + stackSizeArgument + "functionObject" + arguments + ");") + + argumentTypes + ">(functionObject" + arguments + ");") + Line("}"); functionObjects.setRepeatCount(repeats); // function objects by pointer Repeater functionObjectsPointer = Line ("template <typename FunctionObject" + typenameArgumentTypes + ">") + - Line (nameReturn + stackSizeParameter + "FunctionObject *functionObject" + functionParameters + ")") + + Line (nameReturn + "(" + "FunctionObject *functionObject" + functionParameters + ")") + Line("{") + Line(" return new StoredFunctorPointerCall" + Counter() + "<FunctionObject" + - argumentTypes + ">(" + stackSizeArgument + "functionObject" + arguments + ");") + + argumentTypes + ">(functionObject" + arguments + ");") + Line("}"); functionObjectsPointer.setRepeatCount(repeats); // member functions by value Repeater memberFunction = Line ("template <typename Class" + typenameTypes + ">") + - Line (nameReturn + stackSizeParameter + "const Class &object, void (Class::*fn)(" + parameterTypesNoPrefix + ")" + functionParameters + ")") + + Line (nameReturn + "(" + "const Class &object, void (Class::*fn)(" + parameterTypesNoPrefix + ")" + functionParameters + ")") + Line("{") + Line(" return new StoredMemberFunctionCall" + Counter() + "<Class" + - types + ">(" + stackSizeArgument + "fn, object" + arguments + ");") + + types + ">(fn, object" + arguments + ");") + Line("}"); memberFunction.setRepeatCount(repeats); // const member functions by value Repeater constMemberFunction = Line ("template <typename Class" + typenameTypes + ">") + - Line (nameReturn + stackSizeParameter + "const Class &object, void (Class::*fn)(" + parameterTypesNoPrefix + ") const" + functionParameters + ")") + + Line (nameReturn + "(" + "const Class &object, void (Class::*fn)(" + parameterTypesNoPrefix + ") const" + functionParameters + ")") + Line("{") + Line(" return new StoredConstMemberFunctionCall" + Counter() + "<Class" + - types + ">(" + stackSizeArgument + "fn, object" + arguments + ");") + + types + ">(fn, object" + arguments + ");") + Line("}"); constMemberFunction.setRepeatCount(repeats); // member functions by class pointer Repeater memberFunctionPointer = Line ("template <typename Class" + typenameTypes + ">") + - Line (nameReturn + stackSizeParameter + "Class *object, void (Class::*fn)(" + parameterTypesNoPrefix + ")" + functionParameters + ")") + + Line (nameReturn + "(" + "Class *object, void (Class::*fn)(" + parameterTypesNoPrefix + ")" + functionParameters + ")") + Line("{") + Line(" return new StoredMemberFunctionPointerCall" + Counter() + "<Class" + - types + ">(" + stackSizeArgument + "fn, object" + arguments + ");") + + types + ">(fn, object" + arguments + ");") + Line("}"); memberFunctionPointer.setRepeatCount(repeats); // const member functions by class pointer Repeater constMemberFunctionPointer = Line ("template <typename Class" + typenameTypes + ">") + - Line (nameReturn + stackSizeParameter + "const Class *object, void (Class::*fn)(" + parameterTypesNoPrefix + ") const" + functionParameters + ")") + + Line (nameReturn + "(" + "const Class *object, void (Class::*fn)(" + parameterTypesNoPrefix + ") const" + functionParameters + ")") + Line("{") + Line(" return new StoredConstMemberFunctionPointerCall" + Counter() + "<Class" + - types + ">(" + stackSizeArgument + "fn, object" + arguments + ");") + + types + ">(fn, object" + arguments + ");") + Line("}"); constMemberFunctionPointer.setRepeatCount(repeats); @@ -183,48 +179,45 @@ Item generateBuildFunctionDefinitions(int repeats) Item generateBuildFunctionDeclarations(int repeats) { - Item functionPointerType = "void (*)(" + parameterTypesNoPrefix + ")"; + Item nameReturn = "static Coroutine* build"; + Item functionPointerType = "void (*)(" + parameterTypesNoPrefix + ")"; Item functionPointerParameter = "void (*functionPointer)(" + parameterTypesNoPrefix + ")"; - Item stackSizeParameter = "int stackSize, "; - Item stackSizeArgument = "stackSize, "; - - // plain functions Repeater functions = Line (typenameTypesWithTemplate) + - Line ("static Coroutine* build(" + stackSizeParameter + functionPointerParameter + functionParameters + ");"); + Line (nameReturn + "(" + functionPointerParameter + functionParameters + ");"); functions.setRepeatCount(repeats); // function objects by value Repeater functionObjects = Line ("template <typename FunctionObject" + typenameArgumentTypes + ">") + - Line ("static Coroutine* build(" + stackSizeParameter + "FunctionObject functionObject" + functionParameters + ");"); + Line (nameReturn + "(FunctionObject functionObject" + functionParameters + ");"); functionObjects.setRepeatCount(repeats); // function objects by pointer Repeater functionObjectsPointer = Line ("template <typename FunctionObject" + typenameArgumentTypes + ">") + - Line ("static Coroutine* build(" + stackSizeParameter + "FunctionObject *functionObject" + functionParameters + ");"); + Line (nameReturn + "(FunctionObject *functionObject" + functionParameters + ");"); functionObjectsPointer.setRepeatCount(repeats); // member functions by value Repeater memberFunction = Line ("template <typename Class" + typenameTypes + ">") + - Line ("static Coroutine* build(" + stackSizeParameter + "const Class &object, void (Class::*fn)(" + parameterTypesNoPrefix + ")" + functionParameters + ");"); + Line (nameReturn + "(const Class &object, void (Class::*fn)(" + parameterTypesNoPrefix + ")" + functionParameters + ");"); memberFunction.setRepeatCount(repeats); // const member functions by value Repeater constMemberFunction = Line ("template <typename Class" + typenameTypes + ">") + - Line ("static Coroutine *build(" + stackSizeParameter + "const Class &object, void (Class::*fn)(" + parameterTypesNoPrefix + ") const" + functionParameters + ");"); + Line (nameReturn + "(const Class &object, void (Class::*fn)(" + parameterTypesNoPrefix + ") const" + functionParameters + ");"); constMemberFunction.setRepeatCount(repeats); // member functions by class pointer Repeater memberFunctionPointer = Line ("template <typename Class" + typenameTypes + ">") + - Line ("static Coroutine* build(" + stackSizeParameter + "Class *object, void (Class::*fn)(" + parameterTypesNoPrefix + ")" + functionParameters + ");"); + Line (nameReturn + "(Class *object, void (Class::*fn)(" + parameterTypesNoPrefix + ")" + functionParameters + ");"); memberFunctionPointer.setRepeatCount(repeats); // const member functions by class pointer Repeater constMemberFunctionPointer = Line ("template <typename Class" + typenameTypes + ">") + - Line ("static Coroutine* build(" + stackSizeParameter + "const Class *object, void (Class::*fn)(" + parameterTypesNoPrefix + ") const" + functionParameters + ");"); + Line (nameReturn + "(const Class *object, void (Class::*fn)(" + parameterTypesNoPrefix + ") const" + functionParameters + ");"); constMemberFunctionPointer.setRepeatCount(repeats); @@ -240,8 +233,8 @@ Item functions(Item className, Item functorType, Item callLine) Line("template <typename FunctionPointer" + typenameArgumentTypes + ">") + Line("struct " + className + Counter() +": public Coroutine") + Line("{") + - Line(" inline " + className + Counter() + "(int stackSize, " + functorType + " function" + functionParameters +")") + - Line(" : Coroutine(stackSize), function(function)" + initializers + " {}") + + Line(" inline " + className + Counter() + "(" + functorType + " function" + functionParameters +")") + + Line(" : function(function)" + initializers + " {}") + Line("protected:") + Line(" virtual void run() { " + callLine + argumentsNoPrefix + "); }") + Line(" " + functorType + " function;") + @@ -257,8 +250,8 @@ Item memberFunctions(Item className, Item constFunction, Item objectArgument, It Line("class " + className + Counter() + " : public Coroutine") + Line("{") + Line("public:")+ - Line(" " + className + Counter() + "(int stackSize, void (Class::*fn)(" + parameterTypesNoPrefix + ") " + constFunction + ", " + objectArgument + functionParameters + ")") + - Line(" : Coroutine(stackSize), fn(fn), object(object)" + initializers + "{ }" ) + + Line(" " + className + Counter() + "(void (Class::*fn)(" + parameterTypesNoPrefix + ") " + constFunction + ", " + objectArgument + functionParameters + ")") + + Line(" : fn(fn), object(object)" + initializers + "{ }" ) + Line("protected:") + Line(" virtual void run()")+ Line(" {")+ @@ -336,7 +329,7 @@ int main() Line("") + Line("#ifdef qdoc") + Line("") + - Line(" static Coroutine* build(int stackSize, Function function, ...);") + + Line(" static Coroutine* build(Function function, ...);") + Line("") + Line("#else") + Line("") + |