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.178 by root, Wed Oct 3 01:48:06 2007 UTC vs.
Revision 1.179 by root, Wed Oct 3 16:03:17 2007 UTC

582} 582}
583 583
584/** coroutine stack handling ************************************************/ 584/** coroutine stack handling ************************************************/
585 585
586static void 586static void
587setup_coro (pTHX_ struct coro *coro) 587coro_setup (pTHX_ struct coro *coro)
588{ 588{
589 /* 589 /*
590 * emulate part of the perl startup here. 590 * emulate part of the perl startup here.
591 */ 591 */
592 coro_init_stacks (aTHX); 592 coro_init_stacks (aTHX);
601 PL_restartop = 0; 601 PL_restartop = 0;
602 602
603 GvSV (PL_defgv) = NEWSV (0, 0); 603 GvSV (PL_defgv) = NEWSV (0, 0);
604 GvAV (PL_defgv) = coro->args; coro->args = 0; 604 GvAV (PL_defgv) = coro->args; coro->args = 0;
605 GvSV (PL_errgv) = NEWSV (0, 0); 605 GvSV (PL_errgv) = NEWSV (0, 0);
606 GvSV (irsgv) = newSVsv (PL_rs); 606 GvSV (irsgv) = newSVpvn ("\n", 1); sv_magic (GvSV (irsgv), irsgv, PERL_MAGIC_sv, "/", 1);
607 PL_rs = newSVpvn ("\n", 1); 607 PL_rs = newSVsv (GvSV (irsgv));
608 608
609 { 609 {
610 IO *io = newIO (); 610 IO *io = newIO ();
611 GvIOp(PL_defoutgv) = io; 611 GvIOp(PL_defoutgv) = io;
612 IoTYPE (io) = IoTYPE_WRONLY; 612 IoTYPE (io) = IoTYPE_WRONLY;
632 632
633 ENTER; /* necessary e.g. for dounwind */ 633 ENTER; /* necessary e.g. for dounwind */
634} 634}
635 635
636static void 636static void
637destroy_coro (pTHX_ struct coro *coro) 637coro_destroy (pTHX_ struct coro *coro)
638{ 638{
639 if (!IN_DESTRUCT) 639 if (!IN_DESTRUCT)
640 { 640 {
641 /* restore all saved variables and stuff */ 641 /* restore all saved variables and stuff */
642 LEAVE_SCOPE (0); 642 LEAVE_SCOPE (0);
1017 /* need to start coroutine */ 1017 /* need to start coroutine */
1018 next->flags &= ~CF_NEW; 1018 next->flags &= ~CF_NEW;
1019 /* first get rid of the old state */ 1019 /* first get rid of the old state */
1020 save_perl (aTHX_ prev); 1020 save_perl (aTHX_ prev);
1021 /* setup coroutine call */ 1021 /* setup coroutine call */
1022 setup_coro (aTHX_ next); 1022 coro_setup (aTHX_ next);
1023 } 1023 }
1024 else 1024 else
1025 { 1025 {
1026 /* coroutine already started */ 1026 /* coroutine already started */
1027 save_perl (aTHX_ prev); 1027 save_perl (aTHX_ prev);
1095 croak ("FATAL: tried to destroy currently running coroutine"); 1095 croak ("FATAL: tried to destroy currently running coroutine");
1096 1096
1097 save_perl (aTHX_ &temp); 1097 save_perl (aTHX_ &temp);
1098 load_perl (aTHX_ coro); 1098 load_perl (aTHX_ coro);
1099 1099
1100 destroy_coro (aTHX_ coro); 1100 coro_destroy (aTHX_ coro);
1101 1101
1102 load_perl (aTHX_ &temp); /* this will get rid of defsv etc.. */ 1102 load_perl (aTHX_ &temp); /* this will get rid of defsv etc.. */
1103 1103
1104 coro->mainstack = 0; 1104 coro->mainstack = 0;
1105 } 1105 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines