ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/Coro/State.xs
(Generate patch)

Comparing Coro/Coro/State.xs (file contents):
Revision 1.46 by pcg, Wed Nov 5 20:02:46 2003 UTC vs.
Revision 1.47 by pcg, Sat Nov 15 03:53:10 2003 UTC

303#define SE } while (0) 303#define SE } while (0)
304 304
305#define LOAD(state) load_state(aTHX_ (state)); 305#define LOAD(state) load_state(aTHX_ (state));
306#define SAVE(state,flags) save_state(aTHX_ (state),(flags)); 306#define SAVE(state,flags) save_state(aTHX_ (state),(flags));
307 307
308#define REPLACE_SV(sv,val) SB SvREFCNT_dec(sv); (sv) = (val); SE 308#define REPLACE_SV(sv,val) SB SvREFCNT_dec(sv); (sv) = (val); (val) = 0; SE
309 309
310static void 310static void
311load_state(pTHX_ Coro__State c) 311load_state(pTHX_ Coro__State c)
312{ 312{
313 PL_dowarn = c->dowarn; 313 PL_dowarn = c->dowarn;
609 { 609 {
610#ifdef HAVE_MMAP 610#ifdef HAVE_MMAP
611 if (stack->ssize > 0 && stack->sptr) 611 if (stack->ssize > 0 && stack->sptr)
612 munmap (stack->sptr, stack->ssize); 612 munmap (stack->sptr, stack->ssize);
613 else 613 else
614#else 614#endif
615 Safefree (stack->sptr); 615 Safefree (stack->sptr);
616#endif 616
617 Safefree (stack); 617 Safefree (stack);
618 } 618 }
619 else if (ctx->gencnt == stack->gencnt) 619 else if (ctx->gencnt == stack->gencnt)
620 --stack->usecnt; 620 --stack->usecnt;
621 } 621 }
633 633
634 coro_init_stacks (aTHX); 634 coro_init_stacks (aTHX);
635 /*PL_curcop = 0;*/ 635 /*PL_curcop = 0;*/
636 /*PL_in_eval = PL_in_eval;*/ /* inherit */ 636 /*PL_in_eval = PL_in_eval;*/ /* inherit */
637 SvREFCNT_dec (GvAV (PL_defgv)); 637 SvREFCNT_dec (GvAV (PL_defgv));
638 GvAV (PL_defgv) = ctx->args; 638 GvAV (PL_defgv) = ctx->args; ctx->args = 0;
639 639
640 SPAGAIN; 640 SPAGAIN;
641 641
642 if (ctx->stack) 642 if (ctx->stack)
643 { 643 {
765 next->stack = prev->stack; 765 next->stack = prev->stack;
766 next->gencnt = prev->gencnt; 766 next->gencnt = prev->gencnt;
767 } 767 }
768 else 768 else
769 { 769 {
770 assert (!next->stack);
770 allocate_stack (next, 1); 771 allocate_stack (next, 1);
771 coro_create (&(next->stack->cctx), 772 coro_create (&(next->stack->cctx),
772 setup_coro, (void *)next, 773 setup_coro, (void *)next,
773 next->stack->sptr, labs (next->stack->ssize)); 774 next->stack->sptr, labs (next->stack->ssize));
774 coro_transfer (&(prev->stack->cctx), &(next->stack->cctx)); 775 coro_transfer (&(prev->stack->cctx), &(next->stack->cctx));
952 Coro__State coro; 953 Coro__State coro;
953 954
954 if (!SvROK (args) || SvTYPE (SvRV (args)) != SVt_PVAV) 955 if (!SvROK (args) || SvTYPE (SvRV (args)) != SVt_PVAV)
955 croak ("Coro::State::_newprocess expects an arrayref"); 956 croak ("Coro::State::_newprocess expects an arrayref");
956 957
957 New (0, coro, 1, struct coro); 958 Newz (0, coro, 1, struct coro);
958 959
959 coro->args = (AV *)SvREFCNT_inc (SvRV (args)); 960 coro->args = (AV *)SvREFCNT_inc (SvRV (args));
960 coro->mainstack = 0; /* actual work is done inside transfer */ 961 coro->mainstack = 0; /* actual work is done inside transfer */
961 coro->stack = 0; 962 coro->stack = 0;
962 963
963 /* same as JMPENV_BOOTSTRAP */ 964 /* same as JMPENV_BOOTSTRAP */
964 /* we might be able to recycle start_env, but safe is safe */ 965 /* we might be able to recycle start_env, but safe is safe */
965 Zero(&coro->start_env, 1, JMPENV); 966 //Zero(&coro->start_env, 1, JMPENV);
966 coro->start_env.je_ret = -1; 967 coro->start_env.je_ret = -1;
967 coro->start_env.je_mustcatch = TRUE; 968 coro->start_env.je_mustcatch = TRUE;
968 969
969 RETVAL = coro; 970 RETVAL = coro;
970 OUTPUT: 971 OUTPUT:
1004 1005
1005 coro->mainstack = 0; 1006 coro->mainstack = 0;
1006 } 1007 }
1007 1008
1008 deallocate_stack (coro); 1009 deallocate_stack (coro);
1009 1010 SvREFCNT_dec (coro->args);
1010 Safefree (coro); 1011 Safefree (coro);
1011 1012
1012void 1013void
1013flush() 1014flush()
1014 CODE: 1015 CODE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines