summaryrefslogtreecommitdiffstats
path: root/src/coroutine.cpp
diff options
context:
space:
mode:
authorChristian Kamm <christian.d.kamm@nokia.com>2010-03-23 09:25:42 +0100
committerChristian Kamm <christian.d.kamm@nokia.com>2010-03-26 13:05:03 +0100
commitf4dde2601b3fc5c495b563c61c57d949eed17afb (patch)
tree1fc0a890e0917f41475601f7b74b9e72738f0ee3 /src/coroutine.cpp
parentf05141cc12f73daf5901b5bfe5d1271b3a4f8449 (diff)
Documentation updates.
Diffstat (limited to 'src/coroutine.cpp')
-rw-r--r--src/coroutine.cpp26
1 files changed, 22 insertions, 4 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);