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.70 by root, Mon Dec 26 19:26:52 2005 UTC vs.
Revision 1.75 by root, Thu Oct 26 06:50:20 2006 UTC

171 av_store (newpadlist, 1, (SV *) newpad); 171 av_store (newpadlist, 1, (SV *) newpad);
172 172
173 av = newAV (); /* will be @_ */ 173 av = newAV (); /* will be @_ */
174 av_extend (av, 0); 174 av_extend (av, 0);
175 av_store (newpad, 0, (SV *) av); 175 av_store (newpad, 0, (SV *) av);
176 AvFLAGS (av) = AVf_REIFY; 176 AvREIFY_on (av);
177 177
178 for (ix = fpad; ix > 0; ix--) 178 for (ix = fpad; ix > 0; ix--)
179 { 179 {
180 SV *namesv = (ix <= fname) ? pname[ix] : Nullsv; 180 SV *namesv = (ix <= fname) ? pname[ix] : Nullsv;
181 181
346 PL_scopestack_ix = c->scopestack_ix; 346 PL_scopestack_ix = c->scopestack_ix;
347 PL_scopestack_max = c->scopestack_max; 347 PL_scopestack_max = c->scopestack_max;
348 PL_savestack = c->savestack; 348 PL_savestack = c->savestack;
349 PL_savestack_ix = c->savestack_ix; 349 PL_savestack_ix = c->savestack_ix;
350 PL_savestack_max = c->savestack_max; 350 PL_savestack_max = c->savestack_max;
351#if PERL_VERSION < 9
351 PL_retstack = c->retstack; 352 PL_retstack = c->retstack;
352 PL_retstack_ix = c->retstack_ix; 353 PL_retstack_ix = c->retstack_ix;
353 PL_retstack_max = c->retstack_max; 354 PL_retstack_max = c->retstack_max;
355#endif
354 PL_curpm = c->curpm; 356 PL_curpm = c->curpm;
355 PL_curcop = c->curcop; 357 PL_curcop = c->curcop;
356 PL_top_env = c->top_env; 358 PL_top_env = c->top_env;
357 359
358 if (c->defav) REPLACE_SV (GvAV (PL_defgv), c->defav); 360 if (c->defav) REPLACE_SV (GvAV (PL_defgv), c->defav);
472 c->scopestack_ix = PL_scopestack_ix; 474 c->scopestack_ix = PL_scopestack_ix;
473 c->scopestack_max = PL_scopestack_max; 475 c->scopestack_max = PL_scopestack_max;
474 c->savestack = PL_savestack; 476 c->savestack = PL_savestack;
475 c->savestack_ix = PL_savestack_ix; 477 c->savestack_ix = PL_savestack_ix;
476 c->savestack_max = PL_savestack_max; 478 c->savestack_max = PL_savestack_max;
479#if PERL_VERSION < 9
477 c->retstack = PL_retstack; 480 c->retstack = PL_retstack;
478 c->retstack_ix = PL_retstack_ix; 481 c->retstack_ix = PL_retstack_ix;
479 c->retstack_max = PL_retstack_max; 482 c->retstack_max = PL_retstack_max;
483#endif
480 c->curpm = PL_curpm; 484 c->curpm = PL_curpm;
481 c->curcop = PL_curcop; 485 c->curcop = PL_curcop;
482 c->top_env = PL_top_env; 486 c->top_env = PL_top_env;
483} 487}
484 488
521 525
522 New(54,PL_savestack,96,ANY); 526 New(54,PL_savestack,96,ANY);
523 PL_savestack_ix = 0; 527 PL_savestack_ix = 0;
524 PL_savestack_max = 96; 528 PL_savestack_max = 96;
525 529
530#if PERL_VERSION < 9
526 New(54,PL_retstack,8,OP*); 531 New(54,PL_retstack,8,OP*);
527 PL_retstack_ix = 0; 532 PL_retstack_ix = 0;
528 PL_retstack_max = 8; 533 PL_retstack_max = 8;
534#endif
529 535
530 UNLOCK; 536 UNLOCK;
531} 537}
532 538
533/* 539/*
573 579
574 Safefree (PL_tmps_stack); 580 Safefree (PL_tmps_stack);
575 Safefree (PL_markstack); 581 Safefree (PL_markstack);
576 Safefree (PL_scopestack); 582 Safefree (PL_scopestack);
577 Safefree (PL_savestack); 583 Safefree (PL_savestack);
584#if PERL_VERSION < 9
578 Safefree (PL_retstack); 585 Safefree (PL_retstack);
586#endif
579} 587}
580 588
581static void 589static void
582allocate_stack (Coro__State ctx, int alloc) 590allocate_stack (Coro__State ctx, int alloc)
583{ 591{
831 if (!SvOBJECT (sv) || SvSTASH (sv) != coro_state_stash) \ 839 if (!SvOBJECT (sv) || SvSTASH (sv) != coro_state_stash) \
832 croak ("%s() -- %s is not (and contains not) a Coro::State object", func, # sv); \ 840 croak ("%s() -- %s is not (and contains not) a Coro::State object", func, # sv); \
833 \ 841 \
834 } while(0) 842 } while(0)
835 843
836#define SvSTATE(sv) (struct coro *)SvIV (sv) 844#define SvSTATE(sv) INT2PTR (struct coro *, SvIV (sv))
837 845
838static void 846static void
839api_transfer(pTHX_ SV *prev, SV *next, int flags) 847api_transfer(pTHX_ SV *prev, SV *next, int flags)
840{ 848{
841 SV_CORO (prev, "Coro::transfer"); 849 SV_CORO (prev, "Coro::transfer");
859static int coro_nready; 867static int coro_nready;
860 868
861static void 869static void
862coro_enq (pTHX_ SV *sv) 870coro_enq (pTHX_ SV *sv)
863{ 871{
872 SV **xprio;
873 int prio;
874
864 if (SvTYPE (sv) == SVt_PVHV) 875 if (SvTYPE (sv) != SVt_PVHV)
865 {
866 SV **xprio = hv_fetch ((HV *)sv, "prio", 4, 0);
867 int prio = xprio ? SvIV (*xprio) : PRIO_NORMAL;
868
869 prio = prio > PRIO_MAX ? PRIO_MAX
870 : prio < PRIO_MIN ? PRIO_MIN
871 : prio;
872
873 av_push (coro_ready [prio - PRIO_MIN], sv);
874 coro_nready++;
875
876 return;
877 }
878
879 croak ("Coro::ready tried to enqueue something that is not a coroutine"); 876 croak ("Coro::ready tried to enqueue something that is not a coroutine");
877
878 xprio = hv_fetch ((HV *)sv, "prio", 4, 0);
879 prio = xprio ? SvIV (*xprio) : PRIO_NORMAL;
880
881 prio = prio > PRIO_MAX ? PRIO_MAX
882 : prio < PRIO_MIN ? PRIO_MIN
883 : prio;
884
885 av_push (coro_ready [prio - PRIO_MIN], sv);
886 coro_nready++;
880} 887}
881 888
882static SV * 889static SV *
883coro_deq (pTHX_ int min_prio) 890coro_deq (pTHX_ int min_prio)
884{ 891{
1073 av_fill (defav, items - 1); 1080 av_fill (defav, items - 1);
1074 while (items--) 1081 while (items--)
1075 av_store (defav, items, SvREFCNT_inc (ST(items))); 1082 av_store (defav, items, SvREFCNT_inc (ST(items)));
1076 1083
1077 sv = av_pop ((AV *)SvRV (yieldstack)); 1084 sv = av_pop ((AV *)SvRV (yieldstack));
1078 prev = (struct coro *)SvIV ((SV*)SvRV (*av_fetch ((AV *)SvRV (sv), 0, 0))); 1085 prev = INT2PTR (struct coro *, SvIV ((SV*)SvRV (*av_fetch ((AV *)SvRV (sv), 0, 0))));
1079 next = (struct coro *)SvIV ((SV*)SvRV (*av_fetch ((AV *)SvRV (sv), 1, 0))); 1086 next = INT2PTR (struct coro *, SvIV ((SV*)SvRV (*av_fetch ((AV *)SvRV (sv), 1, 0))));
1080 SvREFCNT_dec (sv); 1087 SvREFCNT_dec (sv);
1081 1088
1082 transfer (aTHX_ prev, next, 0); 1089 transfer (aTHX_ prev, next, 0);
1083 1090
1084MODULE = Coro::State PACKAGE = Coro 1091MODULE = Coro::State PACKAGE = Coro

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines