summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Kamm <christian.d.kamm@nokia.com>2010-03-23 11:43:37 +0100
committerChristian Kamm <christian.d.kamm@nokia.com>2010-03-26 13:05:03 +0100
commit396d01725b70a4f5364ac0440dc731a6a5bfc919 (patch)
tree3aa10f6b825d6280b05c74ff2b114162297d87d8
parent505f65860b0dbb292c7eb07112989145c5b8da8c (diff)
More documentation.
-rw-r--r--src/coroutine.cpp46
-rw-r--r--src/coroutine.h2
2 files changed, 37 insertions, 11 deletions
diff --git a/src/coroutine.cpp b/src/coroutine.cpp
index b9ba942..35aaa94 100644
--- a/src/coroutine.cpp
+++ b/src/coroutine.cpp
@@ -42,7 +42,8 @@
/*!
\fn Coroutine *Coroutine::build(Function function, ...)
- \brief Creates a new Coroutine from a callable object.
+
+ 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
@@ -50,6 +51,28 @@
object pointers, the Coroutine object doesn't take ownership.
*/
+/*!
+ \enum Coroutine::Status
+
+ Specifies the current state of a coroutine.
+
+ \value NotStarted Before the first call to cont()
+ \value Running The coroutine is currently running. Note that if a coroutine
+ starts another coroutine, both will be in the Running state. Use
+ currentCoroutine() to get the active one.
+ \value Stopped The coroutine has called yield() at least once but can still be
+ continued with cont().
+ \value Terminated The coroutine has finished executing.
+
+ \sa Coroutine::status()
+*/
+
+/*!
+ \fn Coroutine::Status Coroutine::status() const
+
+ Returns the status of the coroutine.
+*/
+
#ifdef Q_OS_MAC
@@ -79,11 +102,12 @@ Coroutine::~Coroutine()
}
/*!
- \brief Creates a stack of the given size for the coroutine.
-
+ Creates a stack of the given size for the coroutine.
The memory is owned by the Coroutine object and will be deleted on destruction.
Calling this function is only valid when in the NotStarted state.
+
+ \sa setStack()
*/
void Coroutine::createStack(int size)
{
@@ -97,11 +121,12 @@ void Coroutine::createStack(int size)
}
/*!
- \brief Initializes the given area of memory to serve as the stack for the coroutine.
-
+ Initializes the given area of memory to serve as the stack for the coroutine.
The Coroutine object does not take ownership.
Calling this function is only valid when in the NotStarted state.
+
+ \sa createStack()
*/
void Coroutine::setStack(void *memory, int size)
{
@@ -118,7 +143,7 @@ void Coroutine::setStack(void *memory, int size)
static QThreadStorage<Coroutine **> qt_currentCoroutine;
/*!
- \brief Returns the currently running Coroutine.
+ Returns the currently running Coroutine.
*/
Coroutine *Coroutine::currentCoroutine()
{
@@ -142,13 +167,14 @@ void Coroutine::entryPoint()
}
/*!
- \brief Passes control to the coroutine.
-
+ Passes control to the coroutine.
The coroutine will run until it terminates or is stopped by a call to yield().
Returns whether it can be continued again.
Calling this function is only valid if in the NotStarted or Stopped state.
+
+ \sa yield()
*/
bool Coroutine::cont()
{
@@ -167,9 +193,9 @@ bool Coroutine::cont()
}
/*!
- \brief Stops the currently running coroutine.
+ Stops the currently running coroutine and passes control back to the caller of cont().
- And passes control back to the caller of cont().
+ \sa cont()
*/
void Coroutine::yield()
{
diff --git a/src/coroutine.h b/src/coroutine.h
index 08c4108..4e9e959 100644
--- a/src/coroutine.h
+++ b/src/coroutine.h
@@ -22,7 +22,7 @@ public:
bool cont();
static void yield();
- Status status()
+ Status status() const
{ return _status; }
static Coroutine *currentCoroutine();