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.307 by root, Wed Nov 19 14:34:46 2008 UTC vs.
Revision 1.308 by root, Wed Nov 19 15:09:57 2008 UTC

871 dSP; 871 dSP;
872 UNOP myop; 872 UNOP myop;
873 873
874 Zero (&myop, 1, UNOP); 874 Zero (&myop, 1, UNOP);
875 myop.op_next = Nullop; 875 myop.op_next = Nullop;
876 myop.op_type = OP_ENTERSUB;
876 myop.op_flags = OPf_WANT_VOID; 877 myop.op_flags = OPf_WANT_VOID;
877 878
878 PUSHMARK (SP); 879 PUSHMARK (SP);
879 XPUSHs (sv_2mortal (av_shift (GvAV (PL_defgv)))); 880 PUSHs ((SV *)coro->startcv);
880 PUTBACK; 881 PUTBACK;
881 PL_op = (OP *)&myop; 882 PL_op = (OP *)&myop;
882 PL_op = PL_ppaddr[OP_ENTERSUB](aTHX); 883 PL_op = PL_ppaddr[OP_ENTERSUB](aTHX);
883 SPAGAIN;
884 } 884 }
885 885
886 /* this newly created coroutine might be run on an existing cctx which most 886 /* this newly created coroutine might be run on an existing cctx which most
887 * likely was suspended in pp_slf, so we have to emulate entering pp_slf here. 887 * likely was suspended in pp_slf, so we have to emulate entering pp_slf here.
888 */ 888 */
891 891
892 /* and we have to provide the pp_slf op in any case, so pp_slf can skip it */ 892 /* and we have to provide the pp_slf op in any case, so pp_slf can skip it */
893 coro_setup_op.op_next = PL_op; 893 coro_setup_op.op_next = PL_op;
894 coro_setup_op.op_type = OP_CUSTOM; 894 coro_setup_op.op_type = OP_CUSTOM;
895 coro_setup_op.op_ppaddr = pp_slf; 895 coro_setup_op.op_ppaddr = pp_slf;
896 /* no flags required, as an init function won't be called */ 896 /* no flags etc. required, as an init function won't be called */
897 897
898 PL_op = (OP *)&coro_setup_op; 898 PL_op = (OP *)&coro_setup_op;
899 899
900 /* copy throw, in case it was set before coro_setup */ 900 /* copy throw, in case it was set before coro_setup */
901 CORO_THROW = coro->except; 901 CORO_THROW = coro->except;
929 SvREFCNT_dec (GvSV (irsgv)); 929 SvREFCNT_dec (GvSV (irsgv));
930 930
931 SvREFCNT_dec (PL_diehook); 931 SvREFCNT_dec (PL_diehook);
932 SvREFCNT_dec (PL_warnhook); 932 SvREFCNT_dec (PL_warnhook);
933 933
934 SvREFCNT_dec (CORO_THROW);
935 SvREFCNT_dec (coro->saved_deffh); 934 SvREFCNT_dec (coro->saved_deffh);
936 SvREFCNT_dec (coro->rouse_cb); 935 SvREFCNT_dec (coro->rouse_cb);
937 936
938 coro_destruct_stacks (aTHX); 937 coro_destruct_stacks (aTHX);
939} 938}
1144 transfer_tail (aTHX); 1143 transfer_tail (aTHX);
1145 1144
1146 /* somebody or something will hit me for both perl_run and PL_restartop */ 1145 /* somebody or something will hit me for both perl_run and PL_restartop */
1147 PL_restartop = PL_op; 1146 PL_restartop = PL_op;
1148 perl_run (PL_curinterp); 1147 perl_run (PL_curinterp);
1148 /*
1149 * Unfortunately, there is no way to get at the return values of the
1150 * coro body here, as perl_run destroys these
1151 */
1149 1152
1150 /* 1153 /*
1151 * If perl-run returns we assume exit() was being called or the coro 1154 * If perl-run returns we assume exit() was being called or the coro
1152 * fell off the end, which seems to be the only valid (non-bug) 1155 * fell off the end, which seems to be the only valid (non-bug)
1153 * reason for perl_run to return. We try to exit by jumping to the 1156 * reason for perl_run to return. We try to exit by jumping to the
1447 } 1450 }
1448 1451
1449 cctx_destroy (coro->cctx); 1452 cctx_destroy (coro->cctx);
1450 SvREFCNT_dec (coro->startcv); 1453 SvREFCNT_dec (coro->startcv);
1451 SvREFCNT_dec (coro->args); 1454 SvREFCNT_dec (coro->args);
1455 SvREFCNT_dec (CORO_THROW);
1452 1456
1453 if (coro->next) coro->next->prev = coro->prev; 1457 if (coro->next) coro->next->prev = coro->prev;
1454 if (coro->prev) coro->prev->next = coro->next; 1458 if (coro->prev) coro->prev->next = coro->next;
1455 if (coro == coro_first) coro_first = coro->next; 1459 if (coro == coro_first) coro_first = coro->next;
1456 1460
2647 if (items > 1) 2651 if (items > 1)
2648 { 2652 {
2649 coro->startcv = SvREFCNT_inc_NN (cb); 2653 coro->startcv = SvREFCNT_inc_NN (cb);
2650 2654
2651 av_extend (coro->args, items - 1); 2655 av_extend (coro->args, items - 1);
2652 av_push (coro->args, SvREFCNT_inc (cb));
2653 for (i = 2; i < items; i++) 2656 for (i = 2; i < items; i++)
2654 av_push (coro->args, newSVsv (ST (i))); 2657 av_push (coro->args, newSVsv (ST (i)));
2655 } 2658 }
2656} 2659}
2657 OUTPUT: 2660 OUTPUT:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines