#include <ccor.h>
Inheritance diagram for cCoroutine::
Public Methods | |
cCoroutine () | |
~cCoroutine () | |
cCoroutine& | operator= (const cCoroutine &cor) |
bool | setup (CoroutineFnp fnp, void *arg, unsigned stack_size) |
void | destroy () |
void | restart () |
bool | stackOverflow () const |
unsigned | stackSize () const |
unsigned | stackUsage () const |
int | stackLeft () const |
bool | stackLow () const |
Static Public Methods | |
void | init (unsigned total_stack, unsigned main_stack) |
void | switchTo (cCoroutine *cor) |
void | switchtoMain () |
int* | getMainSP () |
Future versions may use platform-specific support for coroutines, such as the Fiber library in the Win32 API.
|
Constructor. |
|
Destructor. |
|
Delete coroutine and release its stack space. |
|
Obsolete. |
|
Initializes the coroutine library. This function has to be called exactly once in a program, possibly at the top of main(). |
|
Assignment is not implemented for coroutines. |
|
Restart the coroutine. |
|
Sets up a coroutine. The arguments are the function that should be run in the coroutine, a pointer that is passed to the coroutine function, and the stack size. |
|
Obsolete. |
|
Obsolete. |
|
Returns true if there was a stack overflow during execution of the coroutine. It checks the intactness of a predefined byte pattern (0xdeadbeef) at the stack boundary, and report stack overflow if it was overwritten. The mechanism usually works fine, but occasionally it can be fooled by large uninitialized local variables (e.g. char buffer[256]): if the byte pattern happens to fall in the middle of such a local variable, it may be preserved intact and stack violation is not detected. |
|
Returns the stack size of the coroutine. This is the same number as the one passed to setup(). |
|
Returns the amount of stack actually used by the coroutine. It works by checking the intactness of predefined byte patterns (0xdeadbeef) placed in the stack. |
|
Switch to another coroutine. The execution of the current coroutine is suspended and the other coroutine is resumed from the point it last left off. |
|
Switch to the main coroutine (the one main() runs in). |