parrotcode: Co-Routine PMC | |
Contents | PMCs |
classes/coroutine.pmc - Co-Routine PMC
Coroutine
extends Continuation
to provide a subroutine that can stop in the middle,
and start back up later at the point at which it stopped.
See the Glossary for more information.
void init()
void *invoke(void *next)
PMC *shift_pmc
)call_hook
below,
a piece of code at the end of a coroutine:INTVAL elements ()
INTVAL elements () {
return (2^31) - 1;
}
PMC* get_iter () {
if (PObj_get_FLAGS(SELF) & PObj_private3_FLAG) {
struct Parrot_coro * sub = PMC_coro(SELF);
PMC *ret = pmc_new(INTERP, enum_class_Coroutine);
struct Parrot_coro * coro = PMC_coro(ret);
coro->end = sub->end;
coro->address = sub->address;
PObj_get_FLAGS(ret) |= PObj_private1_FLAG; /* fixup done */
PObj_get_FLAGS(ret) &= ~PObj_private3_FLAG;
PObj_flag_CLEAR(custom_mark, SELF);
return ret;
}
return SELF;
}
INTVAL get_bool () {
return 1;
}
void mark()
Initial version by Melvin on 2002/06/6.
|