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.152 by root, Thu Sep 20 12:02:25 2007 UTC vs.
Revision 1.153 by root, Thu Sep 20 12:18:00 2007 UTC

210 210
211/* for Coro.pm */ 211/* for Coro.pm */
212static SV *coro_current; 212static SV *coro_current;
213static AV *coro_ready [PRIO_MAX-PRIO_MIN+1]; 213static AV *coro_ready [PRIO_MAX-PRIO_MIN+1];
214static int coro_nready; 214static int coro_nready;
215static struct coro *first; 215static struct coro *coro_first;
216 216
217/** lowlevel stuff **********************************************************/ 217/** lowlevel stuff **********************************************************/
218 218
219static AV * 219static AV *
220coro_clone_padlist (pTHX_ CV *cv) 220coro_clone_padlist (pTHX_ CV *cv)
547{ 547{
548 size_t rss = sizeof (coro); 548 size_t rss = sizeof (coro);
549 549
550 if (coro->mainstack) 550 if (coro->mainstack)
551 { 551 {
552 if (coro->flags & CF_RUNNING)
553 {
554 #define VAR(name,type)coro->name = PL_ ## name;
555 # include "state.h"
556 #undef VAR
557 }
558
552 rss += sizeof (coro->curstackinfo); 559 rss += sizeof (coro->curstackinfo);
553 rss += sizeof (struct xpvav) + (1 + AvFILL (coro->curstackinfo->si_stack)) * sizeof (SV *); 560 rss += sizeof (struct xpvav) + (1 + AvFILL (coro->curstackinfo->si_stack)) * sizeof (SV *);
554 rss += (coro->curstackinfo->si_cxmax + 1) * sizeof (PERL_CONTEXT); 561 rss += (coro->curstackinfo->si_cxmax + 1) * sizeof (PERL_CONTEXT);
555
556 rss += sizeof (struct xpvav) + (1 + AvFILL (coro->curstack)) * sizeof (SV *); 562 rss += sizeof (struct xpvav) + (1 + AvFILL (coro->curstack)) * sizeof (SV *);
557
558 rss += coro->tmps_max * sizeof (SV *); 563 rss += coro->tmps_max * sizeof (SV *);
559
560 rss += (coro->markstack_max - coro->markstack_ptr) * sizeof (I32); 564 rss += (coro->markstack_max - coro->markstack_ptr) * sizeof (I32);
561
562 rss += coro->scopestack_max * sizeof (I32); 565 rss += coro->scopestack_max * sizeof (I32);
563
564 rss += coro->savestack_max * sizeof (ANY); 566 rss += coro->savestack_max * sizeof (ANY);
565 567
566#if !PERL_VERSION_ATLEAST (5,9,0) 568#if !PERL_VERSION_ATLEAST (5,9,0)
567 rss += coro->retstack_max * sizeof (OP *); 569 rss += coro->retstack_max * sizeof (OP *);
568#endif 570#endif
929 cctx_destroy (coro->cctx); 931 cctx_destroy (coro->cctx);
930 SvREFCNT_dec (coro->args); 932 SvREFCNT_dec (coro->args);
931 933
932 if (coro->next) coro->next->prev = coro->prev; 934 if (coro->next) coro->next->prev = coro->prev;
933 if (coro->prev) coro->prev->next = coro->next; 935 if (coro->prev) coro->prev->next = coro->next;
934 if (coro == first) first = coro->next; 936 if (coro == coro_first) coro_first = coro->next;
935 937
936 return 1; 938 return 1;
937} 939}
938 940
939static int 941static int
1247 Newz (0, coro, 1, struct coro); 1249 Newz (0, coro, 1, struct coro);
1248 coro->args = newAV (); 1250 coro->args = newAV ();
1249 coro->save = CORO_SAVE_DEF; 1251 coro->save = CORO_SAVE_DEF;
1250 coro->flags = CF_NEW; 1252 coro->flags = CF_NEW;
1251 1253
1252 if (first) first->prev = coro; 1254 if (coro_first) coro_first->prev = coro;
1253 coro->next = first; 1255 coro->next = coro_first;
1254 first = coro; 1256 coro_first = coro;
1255 1257
1256 coro->hv = hv = newHV (); 1258 coro->hv = hv = newHV ();
1257 sv_magicext ((SV *)hv, 0, PERL_MAGIC_ext, &coro_state_vtbl, (char *)coro, 0)->mg_flags |= MGf_DUP; 1259 sv_magicext ((SV *)hv, 0, PERL_MAGIC_ext, &coro_state_vtbl, (char *)coro, 0)->mg_flags |= MGf_DUP;
1258 RETVAL = sv_bless (newRV_noinc ((SV *)hv), gv_stashpv (klass, 1)); 1260 RETVAL = sv_bless (newRV_noinc ((SV *)hv), gv_stashpv (klass, 1));
1259 1261
1368void 1370void
1369list () 1371list ()
1370 PPCODE: 1372 PPCODE:
1371{ 1373{
1372 struct coro *coro; 1374 struct coro *coro;
1373 for (coro = first; coro; coro = coro->next) 1375 for (coro = coro_first; coro; coro = coro->next)
1374 if (coro->hv) 1376 if (coro->hv)
1375 XPUSHs (sv_2mortal (newRV_inc ((SV *)coro->hv))); 1377 XPUSHs (sv_2mortal (newRV_inc ((SV *)coro->hv)));
1376} 1378}
1377 1379
1378void 1380void

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines