/* Coroutine.pmc
 *  Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
 *  CVS Info
 *     $Id: coroutine.pmc,v 1.23 2003/08/28 08:11:05 leo Exp $
 *  Overview:
 *     These are the vtable functions for the Coroutine base class
 *  Data Structure and Algorithms:
 *  History:
 *     Initial version by Melvin on 2002/06/6
 *  Notes:
 *  References:
 */

#include "parrot/parrot.h"
#include "parrot/method_util.h"

pmclass Coroutine extends Continuation {

    void init () {
        PMC_sub(SELF) = new_coroutine(INTERP);
        SELF->cache.struct_val = NULL;
        PObj_custom_mark_destroy_SETALL(SELF);
        PObj_get_FLAGS(SELF) &= ~PObj_private0_FLAG;
    }


    void* invoke (void* next) {
        void * dest = SELF->cache.struct_val;
        SELF->cache.struct_val = next;
	swap_context(interpreter, SELF);

        return dest;
    }

}
