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.192 by root, Fri Oct 5 21:51:40 2007 UTC vs.
Revision 1.193 by root, Fri Oct 5 23:38:40 2007 UTC

708 bot = PL_stack_base + cx->blk_oldsp + 1; 708 bot = PL_stack_base + cx->blk_oldsp + 1;
709 top = cx->blk_gimme == G_ARRAY ? SP + 1 709 top = cx->blk_gimme == G_ARRAY ? SP + 1
710 : cx->blk_gimme == G_SCALAR ? bot + 1 710 : cx->blk_gimme == G_SCALAR ? bot + 1
711 : bot; 711 : bot;
712 712
713 av_extend (av, top - bot);
713 while (bot < top) 714 while (bot < top)
714 av_push (av, SvREFCNT_inc (*bot++)); 715 av_push (av, SvREFCNT_inc (*bot++));
715 716
716 PL_runops = RUNOPS_DEFAULT; 717 PL_runops = RUNOPS_DEFAULT;
717 ENTER; 718 ENTER;
929 Safefree (cctx->sptr); 930 Safefree (cctx->sptr);
930 931
931 Safefree (cctx); 932 Safefree (cctx);
932} 933}
933 934
935/* wether this cctx should be destructed */
936#define CCTX_EXPIRED(cctx) ((cctx)->ssize < coro_stacksize || ((cctx)->flags & CC_NOREUSE))
937
934static coro_cctx * 938static coro_cctx *
935cctx_get (pTHX) 939cctx_get (pTHX)
936{ 940{
937 while (cctx_first) 941 while (cctx_first)
938 { 942 {
939 coro_cctx *cctx = cctx_first; 943 coro_cctx *cctx = cctx_first;
940 cctx_first = cctx->next; 944 cctx_first = cctx->next;
941 --cctx_idle; 945 --cctx_idle;
942 946
943 if (cctx->ssize >= coro_stacksize && !(cctx->flags & CC_NOREUSE)) 947 if (!CCTX_EXPIRED (cctx))
944 return cctx; 948 return cctx;
945 949
946 cctx_destroy (cctx); 950 cctx_destroy (cctx);
947 } 951 }
948 952
1041 /* I assume that STACKLEVEL is a stronger indicator than PL_top_env changes */ 1045 /* I assume that STACKLEVEL is a stronger indicator than PL_top_env changes */
1042 assert (("ERROR: current top_env must equal previous top_env", PL_top_env == prev__cctx->idle_te)); 1046 assert (("ERROR: current top_env must equal previous top_env", PL_top_env == prev__cctx->idle_te));
1043 1047
1044 prev->cctx = 0; 1048 prev->cctx = 0;
1045 1049
1050 /* if the cctx is about to be destroyed we need to make sure we won't see it in cctx_get */
1051 if (CCTX_EXPIRED (prev__cctx))
1052 next->cctx = cctx_get (aTHX);
1053
1046 cctx_put (prev__cctx); 1054 cctx_put (prev__cctx);
1047 } 1055 }
1048 1056
1049 ++next->usecount; 1057 ++next->usecount;
1050 1058
1429 coro->hv = hv = newHV (); 1437 coro->hv = hv = newHV ();
1430 sv_magicext ((SV *)hv, 0, PERL_MAGIC_ext, &coro_state_vtbl, (char *)coro, 0)->mg_flags |= MGf_DUP; 1438 sv_magicext ((SV *)hv, 0, PERL_MAGIC_ext, &coro_state_vtbl, (char *)coro, 0)->mg_flags |= MGf_DUP;
1431 RETVAL = sv_bless (newRV_noinc ((SV *)hv), gv_stashpv (klass, 1)); 1439 RETVAL = sv_bless (newRV_noinc ((SV *)hv), gv_stashpv (klass, 1));
1432 1440
1433 av_extend (coro->args, items - 1); 1441 av_extend (coro->args, items - 1);
1434
1435 for (i = 1; i < items; i++) 1442 for (i = 1; i < items; i++)
1436 av_push (coro->args, newSVsv (ST (i))); 1443 av_push (coro->args, newSVsv (ST (i)));
1437} 1444}
1438 OUTPUT: 1445 OUTPUT:
1439 RETVAL 1446 RETVAL

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines