WvStreams
|
WvCont provides "continuations", which are apparently also known as semi-coroutines. More...
#include <wvcont.h>
Classes | |
struct | Data |
Public Member Functions | |
WvCont (const WvContCallback &cb, unsigned long stacksize=64 *1024) | |
Construct a WvCont using an existing WvCallback. | |
WvCont (const WvCont &cb) | |
Copy constructor. | |
~WvCont () | |
Destructor. | |
void * | operator() (void *p1=0) |
call the callback, making p1 the return value of yield() or the parameter to the function, and returning Ret, the argument of yield() or the return value of the function. | |
WvCont (const WvContCallback &cb, unsigned long stacksize=64 *1024) | |
Construct a WvCont using an existing WvCallback. | |
WvCont (const WvCont &cb) | |
Copy constructor. | |
~WvCont () | |
Destructor. | |
void * | operator() (void *p1=0) |
call the callback, making p1 the return value of yield() or the parameter to the function, and returning Ret, the argument of yield() or the return value of the function. | |
Static Public Member Functions | |
static WvCont | current () |
Get a copy of the current WvCont. | |
static void * | yield (void *ret=0) |
"return" from the current callback, giving value 'ret' to the person who called us. | |
static bool | isok () |
Tell us if the current context is "okay", that is, not trying to die. | |
template<typename R , typename T > | |
static R | c_bouncer (T t, void *_cont) |
A templated function that allows you to pass a WvCont wherever a C-style function pointer of the form R func(T, void *userdata) is taken. | |
template<typename R > | |
static R | c_bouncer (void *_cont) |
A templated function that allows you to pass a WvCont wherever a C-style function pointer of the form R func(void *userdata) is taken. | |
static WvCont | current () |
Get a copy of the current WvCont. | |
static void * | yield (void *ret=0) |
"return" from the current callback, giving value 'ret' to the person who called us. | |
static bool | isok () |
Tell us if the current context is "okay", that is, not trying to die. | |
template<typename R , typename T > | |
static R | c_bouncer (T t, void *_cont) |
A templated function that allows you to pass a WvCont wherever a C-style function pointer of the form R func(T, void *userdata) is taken. | |
template<typename R > | |
static R | c_bouncer (void *_cont) |
A templated function that allows you to pass a WvCont wherever a C-style function pointer of the form R func(void *userdata) is taken. | |
Friends | |
struct | Data |
WvCont provides "continuations", which are apparently also known as semi-coroutines.
You can wrap any WvCallback<void*,void*> in a WvCont and make it a "continuable" callback - that is, you can yield() from it and return a value. Next time someone calls your callback, it will be as if yield() has returned (and the parameter to your function is returned from yield()).
Definition at line 29 of file debian/libwvstreams-dev/usr/include/wvstreams/wvcont.h.
WvCont::WvCont | ( | const WvContCallback & | cb, |
unsigned long | stacksize = 64*1024 |
||
) |
WvCont::WvCont | ( | const WvContCallback & | cb, |
unsigned long | stacksize = 64 *1024 |
||
) |
void * WvCont::operator() | ( | void * | p1 = 0 | ) |
|
static |
|
static |
"return" from the current callback, giving value 'ret' to the person who called us.
Next time this callback is called, it's as if yield() had returned, and the parameter to the callback is the value of yield().
Definition at line 222 of file wvcont.cc.
References isok().
Referenced by WvStream::continue_select().
|
static |
|
inlinestatic |
A templated function that allows you to pass a WvCont wherever a C-style function pointer of the form R func(T, void *userdata) is taken.
It's your job to make sure the 'userdata' provided is a pointer to the right WvCont.
Example: typedef bool MyFunc(Obj *obj, void *userdata); WvCont cont; MyFunc *func = &WvCont::c_bouncer<bool,Obj *>; bool b = func(new Obj, &cont);
Definition at line 131 of file debian/libwvstreams-dev/usr/include/wvstreams/wvcont.h.
|
inlinestatic |
A templated function that allows you to pass a WvCont wherever a C-style function pointer of the form R func(void *userdata) is taken.
It's your job to make sure the 'userdata' provided is a pointer to the right WvCont.
Example: typedef bool MyFunc(void *userdata); WvCont cont; MyFunc *func = &WvCont::c_bouncer<bool>; bool b = func(&cont);
Definition at line 152 of file debian/libwvstreams-dev/usr/include/wvstreams/wvcont.h.
|
static |
|
static |
Tell us if the current context is "okay", that is, not trying to die.
If !isok(), you shouldn't yield(), because the caller is just going to keep calling you until you die. Return as soon as you can.
|
inlinestatic |
A templated function that allows you to pass a WvCont wherever a C-style function pointer of the form R func(T, void *userdata) is taken.
It's your job to make sure the 'userdata' provided is a pointer to the right WvCont.
Example: typedef bool MyFunc(Obj *obj, void *userdata); WvCont cont; MyFunc *func = &WvCont::c_bouncer<bool,Obj *>; bool b = func(new Obj, &cont);
Definition at line 131 of file include/wvcont.h.
|
inlinestatic |
A templated function that allows you to pass a WvCont wherever a C-style function pointer of the form R func(void *userdata) is taken.
It's your job to make sure the 'userdata' provided is a pointer to the right WvCont.
Example: typedef bool MyFunc(void *userdata); WvCont cont; MyFunc *func = &WvCont::c_bouncer<bool>; bool b = func(&cont);
Definition at line 152 of file include/wvcont.h.
|
friend |
Definition at line 32 of file debian/libwvstreams-dev/usr/include/wvstreams/wvcont.h.