diff options
author | Christian Kamm <christian.d.kamm@nokia.com> | 2010-03-23 09:25:42 +0100 |
---|---|---|
committer | Christian Kamm <christian.d.kamm@nokia.com> | 2010-03-26 13:05:03 +0100 |
commit | f4dde2601b3fc5c495b563c61c57d949eed17afb (patch) | |
tree | 1fc0a890e0917f41475601f7b74b9e72738f0ee3 | |
parent | f05141cc12f73daf5901b5bfe5d1271b3a4f8449 (diff) |
Documentation updates.
-rw-r--r-- | src/coroutine.cpp | 26 | ||||
-rw-r--r-- | src/coroutinebuilddeclaration_p.h | 2 | ||||
-rw-r--r-- | tools/generatebuild/main.cpp | 2 |
3 files changed, 24 insertions, 6 deletions
diff --git a/src/coroutine.cpp b/src/coroutine.cpp index 03cb618..7497765 100644 --- a/src/coroutine.cpp +++ b/src/coroutine.cpp @@ -11,9 +11,12 @@ Coroutines, also known as fibers, allow managing multiple stacks in the same thread. - \omit ### outdated \endomit - To create a coroutine, subclass Coroutine and override the run() method. To run it, - call cont(). This will execute the code in run() until it calls Coroutine::yield(). + New coroutines are made from functions, functors, etc by invoking Coroutine::build + on them. Alternatively, it's possible to derive from Coroutine and overriding + the run() method. + + 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 continue execution of the coroutine just after the yield(). @@ -25,13 +28,28 @@ qDebug() << "2"; } - MyCoroutine c(&myCoroutine); + Coroutine *c = Coroutine::build(32000, &myCoroutine); qDebug() << "0.5"; c.cont(); // prints 1 qDebug() << "1.5"; c.cont(); // prints 2 */ +/*! + \fn Coroutine *Coroutine::build(int stackSize, Function function, ...) + \brief Creates a new Coroutine from a callable object. + + The callable object, Function, can be a function pointer, functor or + pointer to functor, object and member function pointer, or pointer to object + 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. +*/ + + + #ifdef Q_OS_MAC extern "C" void switchStackInternal(void* to, void** from); void initializeStack(void *data, int size, void (*entry)(), void **stackPointer); diff --git a/src/coroutinebuilddeclaration_p.h b/src/coroutinebuilddeclaration_p.h index b7d51ae..f44b91a 100644 --- a/src/coroutinebuilddeclaration_p.h +++ b/src/coroutinebuilddeclaration_p.h @@ -11,7 +11,7 @@ #ifdef qdoc - static Coroutine* build(Function function, ...); + static Coroutine* build(int stackSize, Function function, ...); #else diff --git a/tools/generatebuild/main.cpp b/tools/generatebuild/main.cpp index 43b141d..fd0c496 100644 --- a/tools/generatebuild/main.cpp +++ b/tools/generatebuild/main.cpp @@ -336,7 +336,7 @@ int main() Line("") + Line("#ifdef qdoc") + Line("") + - Line(" static Coroutine* build(Function function, ...);") + + Line(" static Coroutine* build(int stackSize, Function function, ...);") + Line("") + Line("#else") + Line("") + |