Component index
Section index | Component COROUTINE |
Search |
Type | Object |
Summary | Control cooperating co-routines to perform iteration |
Description | Co-routines are functions actives together. When one function reach a useful state (find a result), it just freeses and let the other continue with the result. When the second is done it gives control to the first, which resumes at the esact point The COROUTINE class makes this trick very easy to use. See the samples. |
bool is_done () | ![]() ![]() | void run () |
bool is_idle () | ![]() ![]() | |
bool is_running () | ![]() ![]() | |
bool next () | ![]() ![]() | |
void restart () | ![]() ![]() | |
void stop () | ![]() ![]() |
No parameter passed to the constructor. The destructor takes care of stopping the co-routine if it is running.
This is true right after object creation or after a restart().
The co-routine is stuck in a yield. It has run somehow and it has not end yet.
Return true if the co-routine reached a yield point, false if the co-routine ended.
The next call to next() will start the co-routine.
Further calls to next() won't have any effect and next() will return false.
The co-routinel starts when the next() method is invoked. The routine must use the yield() fhelper to signal it has reached a proper state. It usually record suitable information in glocal variable so the parent may process the results.
The function returns when the parent calls next() again (or restart() or stop()). The function return -1 if it asked to end quickly without yielding anymore.