--- Coro/Coro/State.xs 2006/11/02 20:00:00 1.80 +++ Coro/Coro/State.xs 2006/11/03 00:56:03 1.81 @@ -102,9 +102,6 @@ } coro_stack; struct coro { - /* the top-level JMPENV for each coroutine, needed to catch dies. */ - JMPENV start_env; - /* the optional C context */ coro_stack *stack; void *cursp; @@ -663,7 +660,7 @@ dTHX; Coro__State ctx = (Coro__State)arg; - PL_top_env = &ctx->start_env; + PL_top_env = &PL_start_env; ctx->cursp = 0; PL_op = PL_op->op_next; @@ -679,6 +676,7 @@ if (prev != next) { + /* has this coro been created yet? */ if (next->mainstack) { LOCK; @@ -727,15 +725,17 @@ SAVE (prev, -1); /* first get rid of the old state */ UNLOCK; + /* create the coroutine for the first time */ if (flags & TRANSFER_SAVE_CCTXT) { if (!prev->stack) allocate_stack (prev, 0); + /* the new coroutine starts with start_env again */ + PL_top_env = &PL_start_env; + if (prev->stack->sptr && flags & TRANSFER_LAZY_STACK) { - PL_top_env = &next->start_env; - setup_coro (next); next->cursp = stacklevel; @@ -954,12 +954,6 @@ /*coro->mainstack = 0; *//*actual work is done inside transfer */ /*coro->stack = 0;*/ - /* same as JMPENV_BOOTSTRAP */ - /* we might be able to recycle start_env, but safe is safe */ - /*Zero (&coro->start_env, 1, JMPENV);*/ - coro->start_env.je_ret = -1; - coro->start_env.je_mustcatch = TRUE; - RETVAL = coro; OUTPUT: RETVAL @@ -1012,8 +1006,6 @@ MODULE = Coro::State PACKAGE = Coro::Cont -# this is slightly dirty (should expose a c-level api) - void yield(...) PROTOTYPE: @ @@ -1044,8 +1036,6 @@ MODULE = Coro::State PACKAGE = Coro -# this is slightly dirty (should expose a c-level api) - BOOT: { int i; @@ -1074,8 +1064,8 @@ coroapi.current = coro_current; GCoroAPI = &coroapi; - sv_setiv(sv, (IV)&coroapi); - SvREADONLY_on(sv); + sv_setiv (sv, (IV)&coroapi); + SvREADONLY_on (sv); } }