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.315 by root, Thu Nov 20 05:25:17 2008 UTC vs.
Revision 1.327 by root, Mon Nov 24 06:07:16 2008 UTC

101# define CvISXSUB_on(cv) (void)cv 101# define CvISXSUB_on(cv) (void)cv
102#endif 102#endif
103#ifndef CvISXSUB 103#ifndef CvISXSUB
104# define CvISXSUB(cv) (CvXSUB (cv) ? TRUE : FALSE) 104# define CvISXSUB(cv) (CvXSUB (cv) ? TRUE : FALSE)
105#endif 105#endif
106#ifndef Newx
107# define Newx(ptr,nitems,type) New (0,ptr,nitems,type)
108#endif
106 109
107/* 5.8.7 */ 110/* 5.8.7 */
108#ifndef SvRV_set 111#ifndef SvRV_set
109# define SvRV_set(s,v) SvRV(s) = (v) 112# define SvRV_set(s,v) SvRV(s) = (v)
110#endif 113#endif
170static AV *main_mainstack; /* used to differentiate between $main and others */ 173static AV *main_mainstack; /* used to differentiate between $main and others */
171static JMPENV *main_top_env; 174static JMPENV *main_top_env;
172static HV *coro_state_stash, *coro_stash; 175static HV *coro_state_stash, *coro_stash;
173static volatile SV *coro_mortal; /* will be freed/thrown after next transfer */ 176static volatile SV *coro_mortal; /* will be freed/thrown after next transfer */
174 177
178static AV *av_destroy; /* destruction queue */
179static SV *sv_manager; /* the manager coro */
180static SV *sv_idle; /* $Coro::idle */
181
175static GV *irsgv; /* $/ */ 182static GV *irsgv; /* $/ */
176static GV *stdoutgv; /* *STDOUT */ 183static GV *stdoutgv; /* *STDOUT */
177static SV *rv_diehook; 184static SV *rv_diehook;
178static SV *rv_warnhook; 185static SV *rv_warnhook;
179static HV *hv_sig; /* %SIG */ 186static HV *hv_sig; /* %SIG */
180 187
181/* async_pool helper stuff */ 188/* async_pool helper stuff */
182static SV *sv_pool_rss; 189static SV *sv_pool_rss;
183static SV *sv_pool_size; 190static SV *sv_pool_size;
184static SV *sv_async_pool_idle; 191static SV *sv_async_pool_idle; /* description string */
185static AV *av_async_pool; 192static AV *av_async_pool; /* idle pool */
186static SV *sv_Coro; 193static SV *sv_Coro; /* class string */
187static CV *cv_pool_handler; 194static CV *cv_pool_handler;
188static CV *cv_coro_state_new; 195static CV *cv_coro_state_new;
189 196
190/* Coro::AnyEvent */ 197/* Coro::AnyEvent */
191static SV *sv_activity; 198static SV *sv_activity;
222 int valgrind_id; 229 int valgrind_id;
223#endif 230#endif
224 unsigned char flags; 231 unsigned char flags;
225} coro_cctx; 232} coro_cctx;
226 233
234coro_cctx *cctx_current; /* the currently running cctx */
235
236/*****************************************************************************/
237
227enum { 238enum {
228 CF_RUNNING = 0x0001, /* coroutine is running */ 239 CF_RUNNING = 0x0001, /* coroutine is running */
229 CF_READY = 0x0002, /* coroutine is ready */ 240 CF_READY = 0x0002, /* coroutine is ready */
230 CF_NEW = 0x0004, /* has never been switched to */ 241 CF_NEW = 0x0004, /* has never been switched to */
231 CF_DESTROYED = 0x0008, /* coroutine data has been freed */ 242 CF_DESTROYED = 0x0008, /* coroutine data has been freed */
236{ 247{
237 SV *defsv; 248 SV *defsv;
238 AV *defav; 249 AV *defav;
239 SV *errsv; 250 SV *errsv;
240 SV *irsgv; 251 SV *irsgv;
252 HV *hinthv;
241#define VAR(name,type) type name; 253#define VAR(name,type) type name;
242# include "state.h" 254# include "state.h"
243#undef VAR 255#undef VAR
244} perl_slots; 256} perl_slots;
245 257
344 GV *gvp; 356 GV *gvp;
345 return sv_2cv (sv, &st, &gvp, 0); 357 return sv_2cv (sv, &st, &gvp, 0);
346} 358}
347 359
348static AV * 360static AV *
349coro_clone_padlist (pTHX_ CV *cv) 361coro_derive_padlist (pTHX_ CV *cv)
350{ 362{
351 AV *padlist = CvPADLIST (cv); 363 AV *padlist = CvPADLIST (cv);
352 AV *newpadlist, *newpad; 364 AV *newpadlist, *newpad;
353 365
354 newpadlist = newAV (); 366 newpadlist = newAV ();
474 CV *cp = Perl_cv_clone (aTHX_ cv); 486 CV *cp = Perl_cv_clone (aTHX_ cv);
475 CvPADLIST (cv) = CvPADLIST (cp); 487 CvPADLIST (cv) = CvPADLIST (cp);
476 CvPADLIST (cp) = 0; 488 CvPADLIST (cp) = 0;
477 SvREFCNT_dec (cp); 489 SvREFCNT_dec (cp);
478#else 490#else
479 CvPADLIST (cv) = coro_clone_padlist (aTHX_ cv); 491 CvPADLIST (cv) = coro_derive_padlist (aTHX_ cv);
480#endif 492#endif
481 } 493 }
482} 494}
483 495
484static void 496static void
506 perl_slots *slot = c->slot; 518 perl_slots *slot = c->slot;
507 c->slot = 0; 519 c->slot = 0;
508 520
509 PL_mainstack = c->mainstack; 521 PL_mainstack = c->mainstack;
510 522
511 GvSV (PL_defgv) = slot->defsv; 523 GvSV (PL_defgv) = slot->defsv;
512 GvAV (PL_defgv) = slot->defav; 524 GvAV (PL_defgv) = slot->defav;
513 GvSV (PL_errgv) = slot->errsv; 525 GvSV (PL_errgv) = slot->errsv;
514 GvSV (irsgv) = slot->irsgv; 526 GvSV (irsgv) = slot->irsgv;
527 GvHV (PL_hintgv) = slot->hinthv;
515 528
516 #define VAR(name,type) PL_ ## name = slot->name; 529 #define VAR(name,type) PL_ ## name = slot->name;
517 # include "state.h" 530 # include "state.h"
518 #undef VAR 531 #undef VAR
519 532
605 c->mainstack = PL_mainstack; 618 c->mainstack = PL_mainstack;
606 619
607 { 620 {
608 perl_slots *slot = c->slot = (perl_slots *)(cxstack + cxstack_ix + 1); 621 perl_slots *slot = c->slot = (perl_slots *)(cxstack + cxstack_ix + 1);
609 622
610 slot->defav = GvAV (PL_defgv); 623 slot->defav = GvAV (PL_defgv);
611 slot->defsv = DEFSV; 624 slot->defsv = DEFSV;
612 slot->errsv = ERRSV; 625 slot->errsv = ERRSV;
613 slot->irsgv = GvSV (irsgv); 626 slot->irsgv = GvSV (irsgv);
627 slot->hinthv = GvHV (PL_hintgv);
614 628
615 #define VAR(name,type) slot->name = PL_ ## name; 629 #define VAR(name,type) slot->name = PL_ ## name;
616 # include "state.h" 630 # include "state.h"
617 #undef VAR 631 #undef VAR
618 } 632 }
834slf_check_nop (pTHX_ struct CoroSLF *frame) 848slf_check_nop (pTHX_ struct CoroSLF *frame)
835{ 849{
836 return 0; 850 return 0;
837} 851}
838 852
853static int
854slf_check_repeat (pTHX_ struct CoroSLF *frame)
855{
856 return 1;
857}
858
839static UNOP coro_setup_op; 859static UNOP coro_setup_op;
840 860
841static void NOINLINE /* noinline to keep it out of the transfer fast path */ 861static void NOINLINE /* noinline to keep it out of the transfer fast path */
842coro_setup (pTHX_ struct coro *coro) 862coro_setup (pTHX_ struct coro *coro)
843{ 863{
848 868
849 PL_runops = RUNOPS_DEFAULT; 869 PL_runops = RUNOPS_DEFAULT;
850 PL_curcop = &PL_compiling; 870 PL_curcop = &PL_compiling;
851 PL_in_eval = EVAL_NULL; 871 PL_in_eval = EVAL_NULL;
852 PL_comppad = 0; 872 PL_comppad = 0;
873 PL_comppad_name = 0;
874 PL_comppad_name_fill = 0;
875 PL_comppad_name_floor = 0;
853 PL_curpm = 0; 876 PL_curpm = 0;
854 PL_curpad = 0; 877 PL_curpad = 0;
855 PL_localizing = 0; 878 PL_localizing = 0;
856 PL_dirty = 0; 879 PL_dirty = 0;
857 PL_restartop = 0; 880 PL_restartop = 0;
858#if PERL_VERSION_ATLEAST (5,10,0) 881#if PERL_VERSION_ATLEAST (5,10,0)
859 PL_parser = 0; 882 PL_parser = 0;
860#endif 883#endif
884 PL_hints = 0;
861 885
862 /* recreate the die/warn hooks */ 886 /* recreate the die/warn hooks */
863 PL_diehook = 0; SvSetMagicSV (*hv_fetch (hv_sig, "__DIE__" , sizeof ("__DIE__" ) - 1, 1), rv_diehook ); 887 PL_diehook = 0; SvSetMagicSV (*hv_fetch (hv_sig, "__DIE__" , sizeof ("__DIE__" ) - 1, 1), rv_diehook );
864 PL_warnhook = 0; SvSetMagicSV (*hv_fetch (hv_sig, "__WARN__", sizeof ("__WARN__") - 1, 1), rv_warnhook); 888 PL_warnhook = 0; SvSetMagicSV (*hv_fetch (hv_sig, "__WARN__", sizeof ("__WARN__") - 1, 1), rv_warnhook);
865 889
866 GvSV (PL_defgv) = newSV (0); 890 GvSV (PL_defgv) = newSV (0);
867 GvAV (PL_defgv) = coro->args; coro->args = 0; 891 GvAV (PL_defgv) = coro->args; coro->args = 0;
868 GvSV (PL_errgv) = newSV (0); 892 GvSV (PL_errgv) = newSV (0);
869 GvSV (irsgv) = newSVpvn ("\n", 1); sv_magic (GvSV (irsgv), (SV *)irsgv, PERL_MAGIC_sv, "/", 0); 893 GvSV (irsgv) = newSVpvn ("\n", 1); sv_magic (GvSV (irsgv), (SV *)irsgv, PERL_MAGIC_sv, "/", 0);
894 GvHV (PL_hintgv) = 0;
870 PL_rs = newSVsv (GvSV (irsgv)); 895 PL_rs = newSVsv (GvSV (irsgv));
871 PL_defoutgv = (GV *)SvREFCNT_inc_NN (stdoutgv); 896 PL_defoutgv = (GV *)SvREFCNT_inc_NN (stdoutgv);
872 897
873 { 898 {
874 dSP; 899 dSP;
892 slf_frame.prepare = prepare_nop; /* provide a nop function for an eventual pp_slf */ 917 slf_frame.prepare = prepare_nop; /* provide a nop function for an eventual pp_slf */
893 slf_frame.check = slf_check_nop; /* signal pp_slf to not repeat */ 918 slf_frame.check = slf_check_nop; /* signal pp_slf to not repeat */
894 919
895 /* and we have to provide the pp_slf op in any case, so pp_slf can skip it */ 920 /* and we have to provide the pp_slf op in any case, so pp_slf can skip it */
896 coro_setup_op.op_next = PL_op; 921 coro_setup_op.op_next = PL_op;
897 coro_setup_op.op_type = OP_CUSTOM; 922 coro_setup_op.op_type = OP_ENTERSUB;
898 coro_setup_op.op_ppaddr = pp_slf; 923 coro_setup_op.op_ppaddr = pp_slf;
899 /* no flags etc. required, as an init function won't be called */ 924 /* no flags etc. required, as an init function won't be called */
900 925
901 PL_op = (OP *)&coro_setup_op; 926 PL_op = (OP *)&coro_setup_op;
902 927
928 SvREFCNT_dec (GvAV (PL_defgv)); 953 SvREFCNT_dec (GvAV (PL_defgv));
929 SvREFCNT_dec (GvSV (PL_errgv)); 954 SvREFCNT_dec (GvSV (PL_errgv));
930 SvREFCNT_dec (PL_defoutgv); 955 SvREFCNT_dec (PL_defoutgv);
931 SvREFCNT_dec (PL_rs); 956 SvREFCNT_dec (PL_rs);
932 SvREFCNT_dec (GvSV (irsgv)); 957 SvREFCNT_dec (GvSV (irsgv));
958 SvREFCNT_dec (GvHV (PL_hintgv));
933 959
934 SvREFCNT_dec (PL_diehook); 960 SvREFCNT_dec (PL_diehook);
935 SvREFCNT_dec (PL_warnhook); 961 SvREFCNT_dec (PL_warnhook);
936 962
937 SvREFCNT_dec (coro->saved_deffh); 963 SvREFCNT_dec (coro->saved_deffh);
955static int 981static int
956runops_trace (pTHX) 982runops_trace (pTHX)
957{ 983{
958 COP *oldcop = 0; 984 COP *oldcop = 0;
959 int oldcxix = -2; 985 int oldcxix = -2;
960 struct coro *coro = SvSTATE_current; /* trace cctx is tied to specific coro */
961 coro_cctx *cctx = coro->cctx;
962 986
963 while ((PL_op = CALL_FPTR (PL_op->op_ppaddr) (aTHX))) 987 while ((PL_op = CALL_FPTR (PL_op->op_ppaddr) (aTHX)))
964 { 988 {
965 PERL_ASYNC_CHECK (); 989 PERL_ASYNC_CHECK ();
966 990
967 if (cctx->flags & CC_TRACE_ALL) 991 if (cctx_current->flags & CC_TRACE_ALL)
968 { 992 {
969 if (PL_op->op_type == OP_LEAVESUB && cctx->flags & CC_TRACE_SUB) 993 if (PL_op->op_type == OP_LEAVESUB && cctx_current->flags & CC_TRACE_SUB)
970 { 994 {
971 PERL_CONTEXT *cx = &cxstack[cxstack_ix]; 995 PERL_CONTEXT *cx = &cxstack[cxstack_ix];
972 SV **bot, **top; 996 SV **bot, **top;
973 AV *av = newAV (); /* return values */ 997 AV *av = newAV (); /* return values */
974 SV **cb; 998 SV **cb;
1011 1035
1012 if (PL_curcop != &PL_compiling) 1036 if (PL_curcop != &PL_compiling)
1013 { 1037 {
1014 SV **cb; 1038 SV **cb;
1015 1039
1016 if (oldcxix != cxstack_ix && cctx->flags & CC_TRACE_SUB) 1040 if (oldcxix != cxstack_ix && cctx_current->flags & CC_TRACE_SUB)
1017 { 1041 {
1018 PERL_CONTEXT *cx = &cxstack[cxstack_ix]; 1042 PERL_CONTEXT *cx = &cxstack[cxstack_ix];
1019 1043
1020 if (CxTYPE (cx) == CXt_SUB && oldcxix < cxstack_ix) 1044 if (CxTYPE (cx) == CXt_SUB && oldcxix < cxstack_ix)
1021 { 1045 {
1022 runops_proc_t old_runops = PL_runops;
1023 dSP; 1046 dSP;
1024 GV *gv = CvGV (cx->blk_sub.cv); 1047 GV *gv = CvGV (cx->blk_sub.cv);
1025 SV *fullname = sv_2mortal (newSV (0)); 1048 SV *fullname = sv_2mortal (newSV (0));
1026 1049
1027 if (isGV (gv)) 1050 if (isGV (gv))
1045 } 1068 }
1046 1069
1047 oldcxix = cxstack_ix; 1070 oldcxix = cxstack_ix;
1048 } 1071 }
1049 1072
1050 if (cctx->flags & CC_TRACE_LINE) 1073 if (cctx_current->flags & CC_TRACE_LINE)
1051 { 1074 {
1052 dSP; 1075 dSP;
1053 1076
1054 PL_runops = RUNOPS_DEFAULT; 1077 PL_runops = RUNOPS_DEFAULT;
1055 ENTER; 1078 ENTER;
1074 1097
1075 TAINT_NOT; 1098 TAINT_NOT;
1076 return 0; 1099 return 0;
1077} 1100}
1078 1101
1079static struct coro_cctx *cctx_ssl_cctx;
1080static struct CoroSLF cctx_ssl_frame; 1102static struct CoroSLF cctx_ssl_frame;
1081 1103
1082static void 1104static void
1083slf_prepare_set_stacklevel (pTHX_ struct coro_transfer_args *ta) 1105slf_prepare_set_stacklevel (pTHX_ struct coro_transfer_args *ta)
1084{ 1106{
1085 ta->prev = (struct coro *)cctx_ssl_cctx;
1086 ta->next = 0; 1107 ta->prev = 0;
1087} 1108}
1088 1109
1089static int 1110static int
1090slf_check_set_stacklevel (pTHX_ struct CoroSLF *frame) 1111slf_check_set_stacklevel (pTHX_ struct CoroSLF *frame)
1091{ 1112{
1094 return frame->check (aTHX_ frame); /* execute the restored frame - there must be one */ 1115 return frame->check (aTHX_ frame); /* execute the restored frame - there must be one */
1095} 1116}
1096 1117
1097/* initialises PL_top_env and injects a pseudo-slf-call to set the stacklevel */ 1118/* initialises PL_top_env and injects a pseudo-slf-call to set the stacklevel */
1098static void NOINLINE 1119static void NOINLINE
1099cctx_prepare (pTHX_ coro_cctx *cctx) 1120cctx_prepare (pTHX)
1100{ 1121{
1101 PL_top_env = &PL_start_env; 1122 PL_top_env = &PL_start_env;
1102 1123
1103 if (cctx->flags & CC_TRACE) 1124 if (cctx_current->flags & CC_TRACE)
1104 PL_runops = runops_trace; 1125 PL_runops = runops_trace;
1105 1126
1106 /* we already must be executing an SLF op, there is no other valid way 1127 /* we already must be executing an SLF op, there is no other valid way
1107 * that can lead to creation of a new cctx */ 1128 * that can lead to creation of a new cctx */
1108 assert (("FATAL: can't prepare slf-less cctx in Coro module (please report)", 1129 assert (("FATAL: can't prepare slf-less cctx in Coro module (please report)",
1109 slf_frame.prepare && PL_op->op_ppaddr == pp_slf)); 1130 slf_frame.prepare && PL_op->op_ppaddr == pp_slf));
1110 1131
1111 /* we must emulate leaving pp_slf, which is done inside slf_check_set_stacklevel */ 1132 /* we must emulate leaving pp_slf, which is done inside slf_check_set_stacklevel */
1112 cctx_ssl_cctx = cctx;
1113 cctx_ssl_frame = slf_frame; 1133 cctx_ssl_frame = slf_frame;
1114 1134
1115 slf_frame.prepare = slf_prepare_set_stacklevel; 1135 slf_frame.prepare = slf_prepare_set_stacklevel;
1116 slf_frame.check = slf_check_set_stacklevel; 1136 slf_frame.check = slf_check_set_stacklevel;
1117} 1137}
1140 /* normally we would need to skip the entersub here */ 1160 /* normally we would need to skip the entersub here */
1141 /* not doing so will re-execute it, which is exactly what we want */ 1161 /* not doing so will re-execute it, which is exactly what we want */
1142 /* PL_nop = PL_nop->op_next */ 1162 /* PL_nop = PL_nop->op_next */
1143 1163
1144 /* inject a fake subroutine call to cctx_init */ 1164 /* inject a fake subroutine call to cctx_init */
1145 cctx_prepare (aTHX_ (coro_cctx *)arg); 1165 cctx_prepare (aTHX);
1146 1166
1147 /* cctx_run is the alternative tail of transfer() */ 1167 /* cctx_run is the alternative tail of transfer() */
1148 transfer_tail (aTHX); 1168 transfer_tail (aTHX);
1149 1169
1150 /* somebody or something will hit me for both perl_run and PL_restartop */ 1170 /* somebody or something will hit me for both perl_run and PL_restartop */
1245cctx_destroy (coro_cctx *cctx) 1265cctx_destroy (coro_cctx *cctx)
1246{ 1266{
1247 if (!cctx) 1267 if (!cctx)
1248 return; 1268 return;
1249 1269
1270 assert (cctx != cctx_current);//D temporary
1271
1250 --cctx_count; 1272 --cctx_count;
1251 coro_destroy (&cctx->cctx); 1273 coro_destroy (&cctx->cctx);
1252 1274
1253 /* coro_transfer creates new, empty cctx's */ 1275 /* coro_transfer creates new, empty cctx's */
1254 if (cctx->sptr) 1276 if (cctx->sptr)
1317 /* TODO: throwing up here is considered harmful */ 1339 /* TODO: throwing up here is considered harmful */
1318 1340
1319 if (expect_true (prev != next)) 1341 if (expect_true (prev != next))
1320 { 1342 {
1321 if (expect_false (!(prev->flags & (CF_RUNNING | CF_NEW)))) 1343 if (expect_false (!(prev->flags & (CF_RUNNING | CF_NEW))))
1322 croak ("Coro::State::transfer called with non-running/new prev Coro::State, but can only transfer from running or new states,"); 1344 croak ("Coro::State::transfer called with a suspended prev Coro::State, but can only transfer from running or new states,");
1323 1345
1324 if (expect_false (next->flags & CF_RUNNING)) 1346 if (expect_false (next->flags & CF_RUNNING))
1325 croak ("Coro::State::transfer called with running next Coro::State, but can only transfer to inactive states,"); 1347 croak ("Coro::State::transfer called with running next Coro::State, but can only transfer to inactive states,");
1326 1348
1327 if (expect_false (next->flags & CF_DESTROYED)) 1349 if (expect_false (next->flags & CF_DESTROYED))
1339transfer (pTHX_ struct coro *prev, struct coro *next, int force_cctx) 1361transfer (pTHX_ struct coro *prev, struct coro *next, int force_cctx)
1340{ 1362{
1341 dSTACKLEVEL; 1363 dSTACKLEVEL;
1342 1364
1343 /* sometimes transfer is only called to set idle_sp */ 1365 /* sometimes transfer is only called to set idle_sp */
1344 if (expect_false (!next)) 1366 if (expect_false (!prev))
1345 { 1367 {
1346 ((coro_cctx *)prev)->idle_sp = STACKLEVEL; 1368 cctx_current->idle_sp = STACKLEVEL;
1347 assert (((coro_cctx *)prev)->idle_te = PL_top_env); /* just for the side-effect when asserts are enabled */ 1369 assert (cctx_current->idle_te = PL_top_env); /* just for the side-effect when asserts are enabled */
1348 } 1370 }
1349 else if (expect_true (prev != next)) 1371 else if (expect_true (prev != next))
1350 { 1372 {
1351 coro_cctx *prev__cctx; 1373 coro_cctx *cctx_prev;
1352 1374
1353 if (expect_false (prev->flags & CF_NEW)) 1375 if (expect_false (prev->flags & CF_NEW))
1354 { 1376 {
1355 /* create a new empty/source context */ 1377 /* create a new empty/source context */
1356 prev->cctx = cctx_new_empty ();
1357 prev->flags &= ~CF_NEW; 1378 prev->flags &= ~CF_NEW;
1358 prev->flags |= CF_RUNNING; 1379 prev->flags |= CF_RUNNING;
1359 } 1380 }
1360 1381
1361 prev->flags &= ~CF_RUNNING; 1382 prev->flags &= ~CF_RUNNING;
1372 coro_setup (aTHX_ next); 1393 coro_setup (aTHX_ next);
1373 } 1394 }
1374 else 1395 else
1375 load_perl (aTHX_ next); 1396 load_perl (aTHX_ next);
1376 1397
1377 prev__cctx = prev->cctx; 1398 assert (!prev->cctx);//D temporary
1378 1399
1379 /* possibly untie and reuse the cctx */ 1400 /* possibly untie and reuse the cctx */
1380 if (expect_true ( 1401 if (expect_true (
1381 prev__cctx->idle_sp == STACKLEVEL 1402 cctx_current->idle_sp == STACKLEVEL
1382 && !(prev__cctx->flags & CC_TRACE) 1403 && !(cctx_current->flags & CC_TRACE)
1383 && !force_cctx 1404 && !force_cctx
1384 )) 1405 ))
1385 { 1406 {
1386 /* I assume that stacklevel is a stronger indicator than PL_top_env changes */ 1407 /* I assume that stacklevel is a stronger indicator than PL_top_env changes */
1387 assert (("FATAL: current top_env must equal previous top_env in Coro (please report)", PL_top_env == prev__cctx->idle_te)); 1408 assert (("FATAL: current top_env must equal previous top_env in Coro (please report)", PL_top_env == cctx_current->idle_te));
1388 1409
1389 prev->cctx = 0;
1390
1391 /* if the cctx is about to be destroyed we need to make sure we won't see it in cctx_get */ 1410 /* if the cctx is about to be destroyed we need to make sure we won't see it in cctx_get. */
1392 /* without this the next cctx_get might destroy the prev__cctx while still in use */ 1411 /* without this the next cctx_get might destroy the running cctx while still in use */
1393 if (expect_false (CCTX_EXPIRED (prev__cctx))) 1412 if (expect_false (CCTX_EXPIRED (cctx_current)))
1394 if (!next->cctx) 1413 if (expect_true (!next->cctx))
1395 next->cctx = cctx_get (aTHX); 1414 next->cctx = cctx_get (aTHX);
1396 1415
1397 cctx_put (prev__cctx); 1416 cctx_put (cctx_current);
1398 } 1417 }
1418 else
1419 prev->cctx = cctx_current;
1399 1420
1400 ++next->usecount; 1421 ++next->usecount;
1401 1422
1402 if (expect_true (!next->cctx)) 1423 cctx_prev = cctx_current;
1403 next->cctx = cctx_get (aTHX); 1424 cctx_current = expect_false (next->cctx) ? next->cctx : cctx_get (aTHX);
1404 1425
1405 if (expect_false (prev__cctx != next->cctx)) 1426 next->cctx = 0;
1427
1428 if (expect_false (cctx_prev != cctx_current))
1406 { 1429 {
1407 prev__cctx->top_env = PL_top_env; 1430 cctx_prev->top_env = PL_top_env;
1408 PL_top_env = next->cctx->top_env; 1431 PL_top_env = cctx_current->top_env;
1409 coro_transfer (&prev__cctx->cctx, &next->cctx->cctx); 1432 coro_transfer (&cctx_prev->cctx, &cctx_current->cctx);
1410 } 1433 }
1411 1434
1412 transfer_tail (aTHX); 1435 transfer_tail (aTHX);
1413 } 1436 }
1414} 1437}
1569{ 1592{
1570 struct coro *coro; 1593 struct coro *coro;
1571 SV *sv_hook; 1594 SV *sv_hook;
1572 void (*xs_hook)(void); 1595 void (*xs_hook)(void);
1573 1596
1574 if (SvROK (coro_sv))
1575 coro_sv = SvRV (coro_sv);
1576
1577 coro = SvSTATE (coro_sv); 1597 coro = SvSTATE (coro_sv);
1578 1598
1579 if (coro->flags & CF_READY) 1599 if (coro->flags & CF_READY)
1580 return 0; 1600 return 0;
1581 1601
1612api_is_ready (pTHX_ SV *coro_sv) 1632api_is_ready (pTHX_ SV *coro_sv)
1613{ 1633{
1614 return !!(SvSTATE (coro_sv)->flags & CF_READY); 1634 return !!(SvSTATE (coro_sv)->flags & CF_READY);
1615} 1635}
1616 1636
1637/* expects to own a reference to next->hv */
1617INLINE void 1638INLINE void
1618prepare_schedule (pTHX_ struct coro_transfer_args *ta) 1639prepare_schedule_to (pTHX_ struct coro_transfer_args *ta, struct coro *next)
1619{ 1640{
1620 SV *prev_sv, *next_sv;
1621
1622 for (;;)
1623 {
1624 next_sv = coro_deq (aTHX);
1625
1626 /* nothing to schedule: call the idle handler */
1627 if (expect_false (!next_sv))
1628 {
1629 dSP;
1630
1631 ENTER;
1632 SAVETMPS;
1633
1634 PUSHMARK (SP);
1635 PUTBACK;
1636 call_sv (get_sv ("Coro::idle", FALSE), G_VOID | G_DISCARD);
1637
1638 FREETMPS;
1639 LEAVE;
1640 continue;
1641 }
1642
1643 ta->next = SvSTATE_hv (next_sv);
1644
1645 /* cannot transfer to destroyed coros, skip and look for next */
1646 if (expect_false (ta->next->flags & CF_DESTROYED))
1647 {
1648 SvREFCNT_dec (next_sv);
1649 /* coro_nready has already been taken care of by destroy */
1650 continue;
1651 }
1652
1653 --coro_nready;
1654 break;
1655 }
1656
1657 /* free this only after the transfer */
1658 prev_sv = SvRV (coro_current); 1641 SV *prev_sv = SvRV (coro_current);
1642
1659 ta->prev = SvSTATE_hv (prev_sv); 1643 ta->prev = SvSTATE_hv (prev_sv);
1644 ta->next = next;
1645
1660 TRANSFER_CHECK (*ta); 1646 TRANSFER_CHECK (*ta);
1661 assert (("FATAL: next coroutine isn't marked as ready in Coro (please report)", ta->next->flags & CF_READY)); 1647
1662 ta->next->flags &= ~CF_READY;
1663 SvRV_set (coro_current, next_sv); 1648 SvRV_set (coro_current, (SV *)next->hv);
1664 1649
1665 free_coro_mortal (aTHX); 1650 free_coro_mortal (aTHX);
1666 coro_mortal = prev_sv; 1651 coro_mortal = prev_sv;
1667} 1652}
1668 1653
1654static void
1655prepare_schedule (pTHX_ struct coro_transfer_args *ta)
1656{
1657 for (;;)
1658 {
1659 SV *next_sv = coro_deq (aTHX);
1660
1661 if (expect_true (next_sv))
1662 {
1663 struct coro *next = SvSTATE_hv (next_sv);
1664
1665 /* cannot transfer to destroyed coros, skip and look for next */
1666 if (expect_false (next->flags & CF_DESTROYED))
1667 SvREFCNT_dec (next_sv); /* coro_nready has already been taken care of by destroy */
1668 else
1669 {
1670 next->flags &= ~CF_READY;
1671 --coro_nready;
1672
1673 prepare_schedule_to (aTHX_ ta, next);
1674 break;
1675 }
1676 }
1677 else
1678 {
1679 /* nothing to schedule: call the idle handler */
1680 if (SvROK (sv_idle)
1681 && SvOBJECT (SvRV (sv_idle)))
1682 {
1683 ++coro_nready; /* hack so that api_ready doesn't invoke ready hook */
1684 api_ready (aTHX_ SvRV (sv_idle));
1685 --coro_nready;
1686 }
1687 else
1688 {
1689 dSP;
1690
1691 ENTER;
1692 SAVETMPS;
1693
1694 PUSHMARK (SP);
1695 PUTBACK;
1696 call_sv (sv_idle, G_VOID | G_DISCARD);
1697
1698 FREETMPS;
1699 LEAVE;
1700 }
1701 }
1702 }
1703}
1704
1669INLINE void 1705INLINE void
1670prepare_cede (pTHX_ struct coro_transfer_args *ta) 1706prepare_cede (pTHX_ struct coro_transfer_args *ta)
1671{ 1707{
1672 api_ready (aTHX_ coro_current); 1708 api_ready (aTHX_ coro_current);
1673 prepare_schedule (aTHX_ ta); 1709 prepare_schedule (aTHX_ ta);
1692{ 1728{
1693 struct coro_transfer_args ta; 1729 struct coro_transfer_args ta;
1694 1730
1695 prepare_schedule (aTHX_ &ta); 1731 prepare_schedule (aTHX_ &ta);
1696 TRANSFER (ta, 1); 1732 TRANSFER (ta, 1);
1733}
1734
1735static void
1736api_schedule_to (pTHX_ SV *coro_sv)
1737{
1738 struct coro_transfer_args ta;
1739 struct coro *next = SvSTATE (coro_sv);
1740
1741 SvREFCNT_inc_NN (coro_sv);
1742 prepare_schedule_to (aTHX_ &ta, next);
1697} 1743}
1698 1744
1699static int 1745static int
1700api_cede (pTHX) 1746api_cede (pTHX)
1701{ 1747{
1730static void 1776static void
1731api_trace (pTHX_ SV *coro_sv, int flags) 1777api_trace (pTHX_ SV *coro_sv, int flags)
1732{ 1778{
1733 struct coro *coro = SvSTATE (coro_sv); 1779 struct coro *coro = SvSTATE (coro_sv);
1734 1780
1781 if (coro->flags & CF_RUNNING)
1782 croak ("cannot enable tracing on a running coroutine, caught");
1783
1735 if (flags & CC_TRACE) 1784 if (flags & CC_TRACE)
1736 { 1785 {
1737 if (!coro->cctx) 1786 if (!coro->cctx)
1738 coro->cctx = cctx_new_run (); 1787 coro->cctx = cctx_new_run ();
1739 else if (!(coro->cctx->flags & CC_TRACE)) 1788 else if (!(coro->cctx->flags & CC_TRACE))
1740 croak ("cannot enable tracing on coroutine with custom stack,"); 1789 croak ("cannot enable tracing on coroutine with custom stack, caught");
1741 1790
1742 coro->cctx->flags |= CC_NOREUSE | (flags & (CC_TRACE | CC_TRACE_ALL)); 1791 coro->cctx->flags |= CC_NOREUSE | (flags & (CC_TRACE | CC_TRACE_ALL));
1743 } 1792 }
1744 else if (coro->cctx && coro->cctx->flags & CC_TRACE) 1793 else if (coro->cctx && coro->cctx->flags & CC_TRACE)
1745 { 1794 {
1748 if (coro->flags & CF_RUNNING) 1797 if (coro->flags & CF_RUNNING)
1749 PL_runops = RUNOPS_DEFAULT; 1798 PL_runops = RUNOPS_DEFAULT;
1750 else 1799 else
1751 coro->slot->runops = RUNOPS_DEFAULT; 1800 coro->slot->runops = RUNOPS_DEFAULT;
1752 } 1801 }
1802}
1803
1804static void
1805coro_call_on_destroy (pTHX_ struct coro *coro)
1806{
1807 SV **on_destroyp = hv_fetch (coro->hv, "_on_destroy", sizeof ("_on_destroy") - 1, 0);
1808 SV **statusp = hv_fetch (coro->hv, "_status", sizeof ("_status") - 1, 0);
1809
1810 if (on_destroyp)
1811 {
1812 AV *on_destroy = (AV *)SvRV (*on_destroyp);
1813
1814 while (AvFILLp (on_destroy) >= 0)
1815 {
1816 dSP; /* don't disturb outer sp */
1817 SV *cb = av_pop (on_destroy);
1818
1819 PUSHMARK (SP);
1820
1821 if (statusp)
1822 {
1823 int i;
1824 AV *status = (AV *)SvRV (*statusp);
1825 EXTEND (SP, AvFILLp (status) + 1);
1826
1827 for (i = 0; i <= AvFILLp (status); ++i)
1828 PUSHs (AvARRAY (status)[i]);
1829 }
1830
1831 PUTBACK;
1832 call_sv (sv_2mortal (cb), G_VOID | G_DISCARD);
1833 }
1834 }
1835}
1836
1837static void
1838slf_init_terminate (pTHX_ struct CoroSLF *frame, CV *cv, SV **arg, int items)
1839{
1840 int i;
1841 HV *hv = (HV *)SvRV (coro_current);
1842 AV *av = newAV ();
1843
1844 av_extend (av, items - 1);
1845 for (i = 0; i < items; ++i)
1846 av_push (av, SvREFCNT_inc_NN (arg [i]));
1847
1848 hv_store (hv, "_status", sizeof ("_status") - 1, newRV_noinc ((SV *)av), 0);
1849
1850 av_push (av_destroy, (SV *)newRV_inc ((SV *)hv)); /* RVinc for perl */
1851 api_ready (aTHX_ sv_manager);
1852
1853 frame->prepare = prepare_schedule;
1854 frame->check = slf_check_repeat;
1753} 1855}
1754 1856
1755/*****************************************************************************/ 1857/*****************************************************************************/
1756/* async pool handler */ 1858/* async pool handler */
1757 1859
1990static void 2092static void
1991slf_init_schedule (pTHX_ struct CoroSLF *frame, CV *cv, SV **arg, int items) 2093slf_init_schedule (pTHX_ struct CoroSLF *frame, CV *cv, SV **arg, int items)
1992{ 2094{
1993 frame->prepare = prepare_schedule; 2095 frame->prepare = prepare_schedule;
1994 frame->check = slf_check_nop; 2096 frame->check = slf_check_nop;
2097}
2098
2099static void
2100slf_prepare_schedule_to (pTHX_ struct coro_transfer_args *ta)
2101{
2102 struct coro *next = (struct coro *)slf_frame.data;
2103
2104 SvREFCNT_inc_NN (next->hv);
2105 prepare_schedule_to (aTHX_ ta, next);
2106}
2107
2108static void
2109slf_init_schedule_to (pTHX_ struct CoroSLF *frame, CV *cv, SV **arg, int items)
2110{
2111 if (!items)
2112 croak ("Coro::schedule_to expects a coroutine argument, caught");
2113
2114 frame->data = (void *)SvSTATE (arg [0]);
2115 frame->prepare = slf_prepare_schedule_to;
2116 frame->check = slf_check_nop;
2117}
2118
2119static void
2120slf_init_cede_to (pTHX_ struct CoroSLF *frame, CV *cv, SV **arg, int items)
2121{
2122 api_ready (aTHX_ SvRV (coro_current));
2123
2124 slf_init_schedule_to (aTHX_ frame, cv, arg, items);
1995} 2125}
1996 2126
1997static void 2127static void
1998slf_init_cede (pTHX_ struct CoroSLF *frame, CV *cv, SV **arg, int items) 2128slf_init_cede (pTHX_ struct CoroSLF *frame, CV *cv, SV **arg, int items)
1999{ 2129{
2145 } 2275 }
2146 else 2276 else
2147 slf_argc = 0; 2277 slf_argc = 0;
2148 2278
2149 PL_op->op_ppaddr = pp_slf; 2279 PL_op->op_ppaddr = pp_slf;
2150 PL_op->op_type = OP_CUSTOM; /* maybe we should leave it at entersub? */ 2280 /*PL_op->op_type = OP_CUSTOM; /* we do behave like entersub still */
2151 2281
2152 PL_op = (OP *)&slf_restore; 2282 PL_op = (OP *)&slf_restore;
2153} 2283}
2154 2284
2155/*****************************************************************************/ 2285/*****************************************************************************/
2619 XSRETURN_EMPTY; 2749 XSRETURN_EMPTY;
2620} 2750}
2621 2751
2622/*****************************************************************************/ 2752/*****************************************************************************/
2623 2753
2754#if CORO_CLONE
2755# include "clone.c"
2756#endif
2757
2624MODULE = Coro::State PACKAGE = Coro::State PREFIX = api_ 2758MODULE = Coro::State PACKAGE = Coro::State PREFIX = api_
2625 2759
2626PROTOTYPES: DISABLE 2760PROTOTYPES: DISABLE
2627 2761
2628BOOT: 2762BOOT:
2632 coro_thx = PERL_GET_CONTEXT; 2766 coro_thx = PERL_GET_CONTEXT;
2633# endif 2767# endif
2634#endif 2768#endif
2635 BOOT_PAGESIZE; 2769 BOOT_PAGESIZE;
2636 2770
2771 cctx_current = cctx_new_empty ();
2772
2637 irsgv = gv_fetchpv ("/" , GV_ADD|GV_NOTQUAL, SVt_PV); 2773 irsgv = gv_fetchpv ("/" , GV_ADD|GV_NOTQUAL, SVt_PV);
2638 stdoutgv = gv_fetchpv ("STDOUT", GV_ADD|GV_NOTQUAL, SVt_PVIO); 2774 stdoutgv = gv_fetchpv ("STDOUT", GV_ADD|GV_NOTQUAL, SVt_PVIO);
2639 2775
2640 orig_sigelem_get = PL_vtbl_sigelem.svt_get; PL_vtbl_sigelem.svt_get = coro_sigelem_get; 2776 orig_sigelem_get = PL_vtbl_sigelem.svt_get; PL_vtbl_sigelem.svt_get = coro_sigelem_get;
2641 orig_sigelem_set = PL_vtbl_sigelem.svt_set; PL_vtbl_sigelem.svt_set = coro_sigelem_set; 2777 orig_sigelem_set = PL_vtbl_sigelem.svt_set; PL_vtbl_sigelem.svt_set = coro_sigelem_set;
2660 2796
2661 { 2797 {
2662 SV *slf = sv_2mortal (newSViv (PTR2IV (pp_slf))); 2798 SV *slf = sv_2mortal (newSViv (PTR2IV (pp_slf)));
2663 2799
2664 if (!PL_custom_op_names) PL_custom_op_names = newHV (); 2800 if (!PL_custom_op_names) PL_custom_op_names = newHV ();
2665 hv_store_ent (PL_custom_op_names, slf, 2801 hv_store_ent (PL_custom_op_names, slf, newSVpv ("coro_slf", 0), 0);
2666 newSVpv ("coro_slf", 0), 0);
2667 2802
2668 if (!PL_custom_op_descs) PL_custom_op_descs = newHV (); 2803 if (!PL_custom_op_descs) PL_custom_op_descs = newHV ();
2669 hv_store_ent (PL_custom_op_descs, slf, 2804 hv_store_ent (PL_custom_op_descs, slf, newSVpv ("coro schedule like function", 0), 0);
2670 newSVpv ("coro schedule like function", 0), 0);
2671 } 2805 }
2672 2806
2673 coroapi.ver = CORO_API_VERSION; 2807 coroapi.ver = CORO_API_VERSION;
2674 coroapi.rev = CORO_API_REVISION; 2808 coroapi.rev = CORO_API_REVISION;
2675 2809
2768void 2902void
2769_exit (int code) 2903_exit (int code)
2770 PROTOTYPE: $ 2904 PROTOTYPE: $
2771 CODE: 2905 CODE:
2772 _exit (code); 2906 _exit (code);
2907
2908SV *
2909clone (Coro::State coro)
2910 CODE:
2911{
2912#if CORO_CLONE
2913 struct coro *ncoro = coro_clone (coro);
2914 MAGIC *mg;
2915 /* TODO: too much duplication */
2916 ncoro->hv = newHV ();
2917 mg = sv_magicext ((SV *)ncoro->hv, 0, CORO_MAGIC_type_state, &coro_state_vtbl, (char *)ncoro, 0);
2918 mg->mg_flags |= MGf_DUP;
2919 RETVAL = sv_bless (newRV_noinc ((SV *)ncoro->hv), SvSTASH (coro->hv));
2920#else
2921 croak ("Coro::State->clone has not been configured into this installation of Coro, realised");
2922#endif
2923}
2924 OUTPUT:
2925 RETVAL
2773 2926
2774int 2927int
2775cctx_stacksize (int new_stacksize = 0) 2928cctx_stacksize (int new_stacksize = 0)
2776 PROTOTYPE: ;$ 2929 PROTOTYPE: ;$
2777 CODE: 2930 CODE:
2898 3051
2899SV * 3052SV *
2900has_cctx (Coro::State coro) 3053has_cctx (Coro::State coro)
2901 PROTOTYPE: $ 3054 PROTOTYPE: $
2902 CODE: 3055 CODE:
2903 RETVAL = boolSV (!!coro->cctx); 3056 /* maybe manage the running flag differently */
3057 RETVAL = boolSV (!!coro->cctx || (coro->flags & CF_RUNNING));
2904 OUTPUT: 3058 OUTPUT:
2905 RETVAL 3059 RETVAL
2906 3060
2907int 3061int
2908is_traced (Coro::State coro) 3062is_traced (Coro::State coro)
2928 3082
2929void 3083void
2930force_cctx () 3084force_cctx ()
2931 PROTOTYPE: 3085 PROTOTYPE:
2932 CODE: 3086 CODE:
2933 SvSTATE_current->cctx->idle_sp = 0; 3087 cctx_current->idle_sp = 0;
2934 3088
2935void 3089void
2936swap_defsv (Coro::State self) 3090swap_defsv (Coro::State self)
2937 PROTOTYPE: $ 3091 PROTOTYPE: $
2938 ALIAS: 3092 ALIAS:
2953 3107
2954BOOT: 3108BOOT:
2955{ 3109{
2956 int i; 3110 int i;
2957 3111
2958 av_async_pool = coro_get_av (aTHX_ "Coro::async_pool", TRUE);
2959 sv_pool_rss = coro_get_sv (aTHX_ "Coro::POOL_RSS" , TRUE); 3112 sv_pool_rss = coro_get_sv (aTHX_ "Coro::POOL_RSS" , TRUE);
2960 sv_pool_size = coro_get_sv (aTHX_ "Coro::POOL_SIZE" , TRUE); 3113 sv_pool_size = coro_get_sv (aTHX_ "Coro::POOL_SIZE" , TRUE);
2961 cv_coro_run = get_cv ( "Coro::_terminate", GV_ADD); 3114 cv_coro_run = get_cv ( "Coro::_terminate", GV_ADD);
2962 cv_coro_terminate = get_cv ( "Coro::terminate" , GV_ADD); 3115 cv_coro_terminate = get_cv ( "Coro::terminate" , GV_ADD);
2963 coro_current = coro_get_sv (aTHX_ "Coro::current" , FALSE); SvREADONLY_on (coro_current); 3116 coro_current = coro_get_sv (aTHX_ "Coro::current" , FALSE); SvREADONLY_on (coro_current);
3117 av_async_pool = coro_get_av (aTHX_ "Coro::async_pool", TRUE);
3118 av_destroy = coro_get_av (aTHX_ "Coro::destroy" , TRUE);
3119 sv_manager = coro_get_sv (aTHX_ "Coro::manager" , TRUE);
3120 sv_idle = coro_get_sv (aTHX_ "Coro::idle" , TRUE);
2964 3121
2965 sv_async_pool_idle = newSVpv ("[async pool idle]", 0); SvREADONLY_on (sv_async_pool_idle); 3122 sv_async_pool_idle = newSVpv ("[async pool idle]", 0); SvREADONLY_on (sv_async_pool_idle);
2966 sv_Coro = newSVpv ("Coro", 0); SvREADONLY_on (sv_Coro); 3123 sv_Coro = newSVpv ("Coro", 0); SvREADONLY_on (sv_Coro);
2967 cv_pool_handler = get_cv ("Coro::pool_handler", GV_ADD); SvREADONLY_on (cv_pool_handler); 3124 cv_pool_handler = get_cv ("Coro::pool_handler", GV_ADD); SvREADONLY_on (cv_pool_handler);
2968 cv_coro_state_new = get_cv ("Coro::State::new", 0); SvREADONLY_on (cv_coro_state_new); 3125 cv_coro_state_new = get_cv ("Coro::State::new", 0); SvREADONLY_on (cv_coro_state_new);
2981 3138
2982 { 3139 {
2983 SV *sv = coro_get_sv (aTHX_ "Coro::API", TRUE); 3140 SV *sv = coro_get_sv (aTHX_ "Coro::API", TRUE);
2984 3141
2985 coroapi.schedule = api_schedule; 3142 coroapi.schedule = api_schedule;
3143 coroapi.schedule_to = api_schedule_to;
2986 coroapi.cede = api_cede; 3144 coroapi.cede = api_cede;
2987 coroapi.cede_notself = api_cede_notself; 3145 coroapi.cede_notself = api_cede_notself;
2988 coroapi.ready = api_ready; 3146 coroapi.ready = api_ready;
2989 coroapi.is_ready = api_is_ready; 3147 coroapi.is_ready = api_is_ready;
2990 coroapi.nready = coro_nready; 3148 coroapi.nready = coro_nready;
2995 SvREADONLY_on (sv); 3153 SvREADONLY_on (sv);
2996 } 3154 }
2997} 3155}
2998 3156
2999void 3157void
3158terminate (...)
3159 CODE:
3160 CORO_EXECUTE_SLF_XS (slf_init_terminate);
3161
3162void
3000schedule (...) 3163schedule (...)
3001 CODE: 3164 CODE:
3002 CORO_EXECUTE_SLF_XS (slf_init_schedule); 3165 CORO_EXECUTE_SLF_XS (slf_init_schedule);
3166
3167void
3168schedule_to (...)
3169 CODE:
3170 CORO_EXECUTE_SLF_XS (slf_init_schedule_to);
3171
3172void
3173cede_to (...)
3174 CODE:
3175 CORO_EXECUTE_SLF_XS (slf_init_cede_to);
3003 3176
3004void 3177void
3005cede (...) 3178cede (...)
3006 CODE: 3179 CODE:
3007 CORO_EXECUTE_SLF_XS (slf_init_cede); 3180 CORO_EXECUTE_SLF_XS (slf_init_cede);
3008 3181
3009void 3182void
3010cede_notself (...) 3183cede_notself (...)
3011 CODE: 3184 CODE:
3012 CORO_EXECUTE_SLF_XS (slf_init_cede_notself); 3185 CORO_EXECUTE_SLF_XS (slf_init_cede_notself);
3186
3187void
3188_cancel (Coro::State self)
3189 CODE:
3190 coro_state_destroy (aTHX_ self);
3191 coro_call_on_destroy (aTHX_ self);
3013 3192
3014void 3193void
3015_set_current (SV *current) 3194_set_current (SV *current)
3016 PROTOTYPE: $ 3195 PROTOTYPE: $
3017 CODE: 3196 CODE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines