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.71 by root, Wed Jan 25 21:43:58 2006 UTC vs.
Revision 1.75 by root, Thu Oct 26 06:50:20 2006 UTC

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#ifdef PL_retstack 351#if PERL_VERSION < 9
352 PL_retstack = c->retstack; 352 PL_retstack = c->retstack;
353 PL_retstack_ix = c->retstack_ix; 353 PL_retstack_ix = c->retstack_ix;
354 PL_retstack_max = c->retstack_max; 354 PL_retstack_max = c->retstack_max;
355#endif 355#endif
356 PL_curpm = c->curpm; 356 PL_curpm = c->curpm;
474 c->scopestack_ix = PL_scopestack_ix; 474 c->scopestack_ix = PL_scopestack_ix;
475 c->scopestack_max = PL_scopestack_max; 475 c->scopestack_max = PL_scopestack_max;
476 c->savestack = PL_savestack; 476 c->savestack = PL_savestack;
477 c->savestack_ix = PL_savestack_ix; 477 c->savestack_ix = PL_savestack_ix;
478 c->savestack_max = PL_savestack_max; 478 c->savestack_max = PL_savestack_max;
479#ifdef PL_retstack 479#if PERL_VERSION < 9
480 c->retstack = PL_retstack; 480 c->retstack = PL_retstack;
481 c->retstack_ix = PL_retstack_ix; 481 c->retstack_ix = PL_retstack_ix;
482 c->retstack_max = PL_retstack_max; 482 c->retstack_max = PL_retstack_max;
483#endif 483#endif
484 c->curpm = PL_curpm; 484 c->curpm = PL_curpm;
525 525
526 New(54,PL_savestack,96,ANY); 526 New(54,PL_savestack,96,ANY);
527 PL_savestack_ix = 0; 527 PL_savestack_ix = 0;
528 PL_savestack_max = 96; 528 PL_savestack_max = 96;
529 529
530#ifdef PL_retstack 530#if PERL_VERSION < 9
531 New(54,PL_retstack,8,OP*); 531 New(54,PL_retstack,8,OP*);
532 PL_retstack_ix = 0; 532 PL_retstack_ix = 0;
533 PL_retstack_max = 8; 533 PL_retstack_max = 8;
534#endif 534#endif
535 535
579 579
580 Safefree (PL_tmps_stack); 580 Safefree (PL_tmps_stack);
581 Safefree (PL_markstack); 581 Safefree (PL_markstack);
582 Safefree (PL_scopestack); 582 Safefree (PL_scopestack);
583 Safefree (PL_savestack); 583 Safefree (PL_savestack);
584#ifdef PL_retstack 584#if PERL_VERSION < 9
585 Safefree (PL_retstack); 585 Safefree (PL_retstack);
586#endif 586#endif
587} 587}
588 588
589static void 589static void
839 if (!SvOBJECT (sv) || SvSTASH (sv) != coro_state_stash) \ 839 if (!SvOBJECT (sv) || SvSTASH (sv) != coro_state_stash) \
840 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); \
841 \ 841 \
842 } while(0) 842 } while(0)
843 843
844#define SvSTATE(sv) (struct coro *)SvIV (sv) 844#define SvSTATE(sv) INT2PTR (struct coro *, SvIV (sv))
845 845
846static void 846static void
847api_transfer(pTHX_ SV *prev, SV *next, int flags) 847api_transfer(pTHX_ SV *prev, SV *next, int flags)
848{ 848{
849 SV_CORO (prev, "Coro::transfer"); 849 SV_CORO (prev, "Coro::transfer");
867static int coro_nready; 867static int coro_nready;
868 868
869static void 869static void
870coro_enq (pTHX_ SV *sv) 870coro_enq (pTHX_ SV *sv)
871{ 871{
872 SV **xprio;
873 int prio;
874
872 if (SvTYPE (sv) == SVt_PVHV) 875 if (SvTYPE (sv) != SVt_PVHV)
873 {
874 SV **xprio = hv_fetch ((HV *)sv, "prio", 4, 0);
875 int prio = xprio ? SvIV (*xprio) : PRIO_NORMAL;
876
877 prio = prio > PRIO_MAX ? PRIO_MAX
878 : prio < PRIO_MIN ? PRIO_MIN
879 : prio;
880
881 av_push (coro_ready [prio - PRIO_MIN], sv);
882 coro_nready++;
883
884 return;
885 }
886
887 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++;
888} 887}
889 888
890static SV * 889static SV *
891coro_deq (pTHX_ int min_prio) 890coro_deq (pTHX_ int min_prio)
892{ 891{
1081 av_fill (defav, items - 1); 1080 av_fill (defav, items - 1);
1082 while (items--) 1081 while (items--)
1083 av_store (defav, items, SvREFCNT_inc (ST(items))); 1082 av_store (defav, items, SvREFCNT_inc (ST(items)));
1084 1083
1085 sv = av_pop ((AV *)SvRV (yieldstack)); 1084 sv = av_pop ((AV *)SvRV (yieldstack));
1086 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))));
1087 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))));
1088 SvREFCNT_dec (sv); 1087 SvREFCNT_dec (sv);
1089 1088
1090 transfer (aTHX_ prev, next, 0); 1089 transfer (aTHX_ prev, next, 0);
1091 1090
1092MODULE = Coro::State PACKAGE = Coro 1091MODULE = Coro::State PACKAGE = Coro

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines