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.157 by root, Fri Sep 21 02:01:13 2007 UTC vs.
Revision 1.168 by root, Thu Sep 27 16:10:48 2007 UTC

88/* prefer perl internal functions over our own? */ 88/* prefer perl internal functions over our own? */
89#ifndef CORO_PREFER_PERL_FUNCTIONS 89#ifndef CORO_PREFER_PERL_FUNCTIONS
90# define CORO_PREFER_PERL_FUNCTIONS 0 90# define CORO_PREFER_PERL_FUNCTIONS 0
91#endif 91#endif
92 92
93/* The next macro should declare a variable stacklevel that contains and approximation 93/* The next macros try to return the current stack pointer, in an as
94 * to the current C stack pointer. Its property is that it changes with each call 94 * portable way as possible. */
95 * and should be unique. */
96#define dSTACKLEVEL int stacklevel 95#define dSTACKLEVEL volatile char stacklevel
97#define STACKLEVEL ((void *)&stacklevel) 96#define STACKLEVEL ((void *)&stacklevel)
98 97
99#define IN_DESTRUCT (PL_main_cv == Nullcv) 98#define IN_DESTRUCT (PL_main_cv == Nullcv)
100 99
101#if __GNUC__ >= 3 100#if __GNUC__ >= 3
133static AV *main_mainstack; /* used to differentiate between $main and others */ 132static AV *main_mainstack; /* used to differentiate between $main and others */
134static JMPENV *main_top_env; 133static JMPENV *main_top_env;
135static HV *coro_state_stash, *coro_stash; 134static HV *coro_state_stash, *coro_stash;
136static SV *coro_mortal; /* will be freed after next transfer */ 135static SV *coro_mortal; /* will be freed after next transfer */
137 136
137/* async_pool helper stuff */
138static SV *sv_pool_rss;
139static SV *sv_pool_size;
140static AV *av_async_pool;
141
138static struct coro_cctx *cctx_first; 142static struct coro_cctx *cctx_first;
139static int cctx_count, cctx_idle; 143static int cctx_count, cctx_idle;
144
145enum {
146 CC_MAPPED = 0x01,
147 CC_NOREUSE = 0x02, /* throw this away after tracing */
148 CC_TRACE = 0x04,
149 CC_TRACE_SUB = 0x08, /* trace sub calls */
150 CC_TRACE_LINE = 0x10, /* trace each statement */
151 CC_TRACE_ALL = CC_TRACE_SUB | CC_TRACE_LINE,
152};
140 153
141/* this is a structure representing a c-level coroutine */ 154/* this is a structure representing a c-level coroutine */
142typedef struct coro_cctx { 155typedef struct coro_cctx {
143 struct coro_cctx *next; 156 struct coro_cctx *next;
144 157
153 coro_context cctx; 166 coro_context cctx;
154 167
155#if CORO_USE_VALGRIND 168#if CORO_USE_VALGRIND
156 int valgrind_id; 169 int valgrind_id;
157#endif 170#endif
158 char inuse, mapped; 171 unsigned char flags;
159} coro_cctx; 172} coro_cctx;
160 173
161enum { 174enum {
162 CF_RUNNING = 0x0001, /* coroutine is running */ 175 CF_RUNNING = 0x0001, /* coroutine is running */
163 CF_READY = 0x0002, /* coroutine is ready */ 176 CF_READY = 0x0002, /* coroutine is ready */
424 437
425 if (top_si->si_type == PERLSI_MAIN) 438 if (top_si->si_type == PERLSI_MAIN)
426 break; 439 break;
427 440
428 top_si = top_si->si_prev; 441 top_si = top_si->si_prev;
429 ccstk = top_si->si_cxstack; 442 ccstk = top_si->si_cxstack;
430 cxix = top_si->si_cxix; 443 cxix = top_si->si_cxix;
431 } 444 }
432 445
433 PUTBACK; 446 PUTBACK;
434 } 447 }
435 448
620 SvREFCNT_dec (coro_mortal); 633 SvREFCNT_dec (coro_mortal);
621 coro_mortal = 0; 634 coro_mortal = 0;
622 } 635 }
623} 636}
624 637
638static int
639runops_coro (pTHX)
640{
641 COP *oldcop = 0;
642 int oldcxix = -2;
643
644 while ((PL_op = CALL_FPTR (PL_op->op_ppaddr) (aTHX)))
645 {
646 PERL_ASYNC_CHECK ();
647
648 if (PL_op->op_type == OP_LEAVESUB)
649 {
650 PERL_CONTEXT *cx = &cxstack[cxstack_ix];
651 SV **bot, **top;
652 AV *av = newAV (); /* return values */
653 runops_proc_t old_runops = PL_runops;
654 dSP;
655 ENTER;
656 SAVETMPS;
657 EXTEND (SP, 3);
658 PL_runops = RUNOPS_DEFAULT;
659
660 GV *gv = CvGV (cx->blk_sub.cv);
661 SV *fullname = sv_2mortal (newSV (0));
662 if (isGV (gv))
663 gv_efullname3 (fullname, gv, 0);
664
665 bot = PL_stack_base + cx->blk_oldsp + 1;
666 top = cx->blk_gimme == G_ARRAY ? SP + 1
667 : cx->blk_gimme == G_SCALAR ? bot + 1
668 : bot;
669
670 while (bot < top)
671 av_push (av, SvREFCNT_inc (*bot++));
672
673 PUSHMARK (SP);
674 PUSHs (&PL_sv_no);
675 PUSHs (fullname);
676 PUSHs (sv_2mortal (newRV_noinc ((SV *)av)));
677 PUTBACK;
678 call_pv ("Coro::_do_trace_sub", G_KEEPERR | G_EVAL | G_VOID | G_DISCARD);
679 SPAGAIN;
680
681 FREETMPS;
682 LEAVE;
683 PL_runops = old_runops;
684 }
685
686 if (oldcop != PL_curcop)
687 {
688 oldcop = PL_curcop;
689
690 if (PL_curcop != &PL_compiling)
691 {
692 runops_proc_t old_runops = PL_runops;
693 dSP;
694 ENTER;
695 SAVETMPS;
696 EXTEND (SP, 3);
697 PL_runops = RUNOPS_DEFAULT;
698
699 if (oldcxix != cxstack_ix)
700 {
701 PERL_CONTEXT *cx = &cxstack[cxstack_ix];
702
703 if (CxTYPE (cx) == CXt_SUB && oldcxix < cxstack_ix)
704 {
705 GV *gv = CvGV (cx->blk_sub.cv);
706 SV *fullname = sv_2mortal (newSV (0));
707 if (isGV (gv))
708 gv_efullname3 (fullname, gv, 0);
709
710 PUSHMARK (SP);
711 PUSHs (&PL_sv_yes);
712 PUSHs (fullname);
713 PUSHs (cx->blk_sub.hasargs ? sv_2mortal (newRV_inc ((SV *)cx->blk_sub.argarray)) : &PL_sv_undef);
714 PUTBACK;
715 call_pv ("Coro::_do_trace_sub", G_KEEPERR | G_EVAL | G_VOID | G_DISCARD);
716 SPAGAIN;
717 }
718
719 oldcxix = cxstack_ix;
720 }
721
722 if (0) {
723 PUSHMARK (SP);
724 PUSHs (sv_2mortal (newSVpv (OutCopFILE (oldcop), 0)));
725 PUSHs (sv_2mortal (newSViv (CopLINE (oldcop))));
726 PUTBACK;
727 call_pv ("Coro::_do_trace_line", G_KEEPERR | G_EVAL | G_VOID | G_DISCARD);
728 SPAGAIN;
729 }
730
731 FREETMPS;
732 LEAVE;
733 PL_runops = old_runops;
734 }
735 }
736 }
737
738 TAINT_NOT;
739 return 0;
740}
741
625/* inject a fake call to Coro::State::_cctx_init into the execution */ 742/* inject a fake call to Coro::State::_cctx_init into the execution */
626/* _cctx_init should be careful, as it could be called at almost any time */ 743/* _cctx_init should be careful, as it could be called at almost any time */
627/* during execution of a perl program */ 744/* during execution of a perl program */
628static void NOINLINE 745static void NOINLINE
629prepare_cctx (pTHX_ coro_cctx *cctx) 746prepare_cctx (pTHX_ coro_cctx *cctx)
630{ 747{
631 dSP; 748 dSP;
632 LOGOP myop; 749 LOGOP myop;
750
751 PL_top_env = &PL_start_env;
752
753 if (cctx->flags & CC_TRACE)
754 PL_runops = runops_coro;
633 755
634 Zero (&myop, 1, LOGOP); 756 Zero (&myop, 1, LOGOP);
635 myop.op_next = PL_op; 757 myop.op_next = PL_op;
636 myop.op_flags = OPf_WANT_VOID | OPf_STACKED; 758 myop.op_flags = OPf_WANT_VOID | OPf_STACKED;
637 759
654 dTHX; 776 dTHX;
655 777
656 /* coro_run is the alternative tail of transfer(), so unlock here. */ 778 /* coro_run is the alternative tail of transfer(), so unlock here. */
657 UNLOCK; 779 UNLOCK;
658 780
659 PL_top_env = &PL_start_env; 781 /* we now skip the entersub that lead to transfer() */
782 PL_op = PL_op->op_next;
660 783
661 /* inject a fake subroutine call to cctx_init */ 784 /* inject a fake subroutine call to cctx_init */
662 prepare_cctx (aTHX_ (coro_cctx *)arg); 785 prepare_cctx (aTHX_ (coro_cctx *)arg);
663 786
664 /* somebody or something will hit me for both perl_run and PL_restartop */ 787 /* somebody or something will hit me for both perl_run and PL_restartop */
698# if CORO_STACKGUARD 821# if CORO_STACKGUARD
699 mprotect (cctx->sptr, CORO_STACKGUARD * PAGESIZE, PROT_NONE); 822 mprotect (cctx->sptr, CORO_STACKGUARD * PAGESIZE, PROT_NONE);
700# endif 823# endif
701 stack_start = CORO_STACKGUARD * PAGESIZE + (char *)cctx->sptr; 824 stack_start = CORO_STACKGUARD * PAGESIZE + (char *)cctx->sptr;
702 stack_size = cctx->ssize - CORO_STACKGUARD * PAGESIZE; 825 stack_size = cctx->ssize - CORO_STACKGUARD * PAGESIZE;
703 cctx->mapped = 1; 826 cctx->flags |= CC_MAPPED;
704 } 827 }
705 else 828 else
706#endif 829#endif
707 { 830 {
708 cctx->ssize = coro_stacksize * (long)sizeof (long); 831 cctx->ssize = coro_stacksize * (long)sizeof (long);
735#if CORO_USE_VALGRIND 858#if CORO_USE_VALGRIND
736 VALGRIND_STACK_DEREGISTER (cctx->valgrind_id); 859 VALGRIND_STACK_DEREGISTER (cctx->valgrind_id);
737#endif 860#endif
738 861
739#if HAVE_MMAP 862#if HAVE_MMAP
740 if (cctx->mapped) 863 if (cctx->flags & CC_MAPPED)
741 munmap (cctx->sptr, cctx->ssize); 864 munmap (cctx->sptr, cctx->ssize);
742 else 865 else
743#endif 866#endif
744 Safefree (cctx->sptr); 867 Safefree (cctx->sptr);
745 868
753 { 876 {
754 coro_cctx *cctx = cctx_first; 877 coro_cctx *cctx = cctx_first;
755 cctx_first = cctx->next; 878 cctx_first = cctx->next;
756 --cctx_idle; 879 --cctx_idle;
757 880
758 if (cctx->ssize >= coro_stacksize) 881 if (cctx->ssize >= coro_stacksize && !(cctx->flags & CC_NOREUSE))
759 return cctx; 882 return cctx;
760 883
761 cctx_destroy (cctx); 884 cctx_destroy (cctx);
762 } 885 }
763 886
764 PL_op = PL_op->op_next;
765 return cctx_new (); 887 return cctx_new ();
766} 888}
767 889
768static void 890static void
769cctx_put (coro_cctx *cctx) 891cctx_put (coro_cctx *cctx)
773 { 895 {
774 coro_cctx *first = cctx_first; 896 coro_cctx *first = cctx_first;
775 cctx_first = first->next; 897 cctx_first = first->next;
776 --cctx_idle; 898 --cctx_idle;
777 899
778 assert (!first->inuse);
779 cctx_destroy (first); 900 cctx_destroy (first);
780 } 901 }
781 902
782 ++cctx_idle; 903 ++cctx_idle;
783 cctx->next = cctx_first; 904 cctx->next = cctx_first;
804 925
805 if (prev->flags & CF_NEW) 926 if (prev->flags & CF_NEW)
806 { 927 {
807 /* create a new empty context */ 928 /* create a new empty context */
808 Newz (0, prev->cctx, 1, coro_cctx); 929 Newz (0, prev->cctx, 1, coro_cctx);
809 prev->cctx->inuse = 1;
810 prev->flags &= ~CF_NEW; 930 prev->flags &= ~CF_NEW;
811 prev->flags |= CF_RUNNING; 931 prev->flags |= CF_RUNNING;
812 } 932 }
813 933
814 /*TODO: must not croak here */ 934 /*TODO: must not croak here */
832 next->flags &= ~CF_NEW; 952 next->flags &= ~CF_NEW;
833 /* first get rid of the old state */ 953 /* first get rid of the old state */
834 save_perl (aTHX_ prev); 954 save_perl (aTHX_ prev);
835 /* setup coroutine call */ 955 /* setup coroutine call */
836 setup_coro (aTHX_ next); 956 setup_coro (aTHX_ next);
837 /* need a new stack */
838 assert (!next->cctx);
839 } 957 }
840 else 958 else
841 { 959 {
842 /* coroutine already started */ 960 /* coroutine already started */
843 save_perl (aTHX_ prev); 961 save_perl (aTHX_ prev);
845 } 963 }
846 964
847 prev__cctx = prev->cctx; 965 prev__cctx = prev->cctx;
848 966
849 /* possibly "free" the cctx */ 967 /* possibly "free" the cctx */
850 if (prev__cctx->idle_sp == STACKLEVEL) 968 if (prev__cctx->idle_sp == STACKLEVEL && !(prev__cctx->flags & CC_TRACE))
851 { 969 {
852 /* I assume that STACKLEVEL is a stronger indicator than PL_top_env changes */ 970 /* I assume that STACKLEVEL is a stronger indicator than PL_top_env changes */
853 assert (("ERROR: current top_env must equal previous top_env", PL_top_env == prev__cctx->idle_te)); 971 assert (("ERROR: current top_env must equal previous top_env", PL_top_env == prev__cctx->idle_te));
854 972
855 prev->cctx = 0; 973 prev->cctx = 0;
856 974
857 cctx_put (prev__cctx); 975 cctx_put (prev__cctx);
858 prev__cctx->inuse = 0;
859 } 976 }
860 977
861 if (!next->cctx) 978 if (!next->cctx)
862 {
863 next->cctx = cctx_get (aTHX); 979 next->cctx = cctx_get (aTHX);
864 assert (!next->cctx->inuse);
865 next->cctx->inuse = 1;
866 }
867 980
868 if (prev__cctx != next->cctx) 981 if (prev__cctx != next->cctx)
869 { 982 {
870 prev__cctx->top_env = PL_top_env; 983 prev__cctx->top_env = PL_top_env;
871 PL_top_env = next->cctx->top_env; 984 PL_top_env = next->cctx->top_env;
1215#endif 1328#endif
1216 BOOT_PAGESIZE; 1329 BOOT_PAGESIZE;
1217 1330
1218 coro_state_stash = gv_stashpv ("Coro::State", TRUE); 1331 coro_state_stash = gv_stashpv ("Coro::State", TRUE);
1219 1332
1333 newCONSTSUB (coro_state_stash, "CC_TRACE" , newSViv (CC_TRACE));
1334 newCONSTSUB (coro_state_stash, "CC_TRACE_SUB" , newSViv (CC_TRACE_SUB));
1335 newCONSTSUB (coro_state_stash, "CC_TRACE_LINE", newSViv (CC_TRACE_LINE));
1336 newCONSTSUB (coro_state_stash, "CC_TRACE_ALL" , newSViv (CC_TRACE_ALL));
1337
1220 newCONSTSUB (coro_state_stash, "SAVE_DEFAV", newSViv (CORO_SAVE_DEFAV)); 1338 newCONSTSUB (coro_state_stash, "SAVE_DEFAV", newSViv (CORO_SAVE_DEFAV));
1221 newCONSTSUB (coro_state_stash, "SAVE_DEFSV", newSViv (CORO_SAVE_DEFSV)); 1339 newCONSTSUB (coro_state_stash, "SAVE_DEFSV", newSViv (CORO_SAVE_DEFSV));
1222 newCONSTSUB (coro_state_stash, "SAVE_ERRSV", newSViv (CORO_SAVE_ERRSV)); 1340 newCONSTSUB (coro_state_stash, "SAVE_ERRSV", newSViv (CORO_SAVE_ERRSV));
1223 newCONSTSUB (coro_state_stash, "SAVE_IRSSV", newSViv (CORO_SAVE_IRSSV)); 1341 newCONSTSUB (coro_state_stash, "SAVE_IRSSV", newSViv (CORO_SAVE_IRSSV));
1224 newCONSTSUB (coro_state_stash, "SAVE_DEFFH", newSViv (CORO_SAVE_DEFFH)); 1342 newCONSTSUB (coro_state_stash, "SAVE_DEFFH", newSViv (CORO_SAVE_DEFFH));
1375 if (coro->hv) 1493 if (coro->hv)
1376 XPUSHs (sv_2mortal (newRV_inc ((SV *)coro->hv))); 1494 XPUSHs (sv_2mortal (newRV_inc ((SV *)coro->hv)));
1377} 1495}
1378 1496
1379void 1497void
1380_eval (Coro::State coro, SV *coderef) 1498call (Coro::State coro, SV *coderef)
1499 ALIAS:
1500 eval = 1
1381 CODE: 1501 CODE:
1382{ 1502{
1383 if (coro->mainstack) 1503 if (coro->mainstack)
1384 { 1504 {
1385 struct coro temp; 1505 struct coro temp;
1396 dSP; 1516 dSP;
1397 ENTER; 1517 ENTER;
1398 SAVETMPS; 1518 SAVETMPS;
1399 PUSHMARK (SP); 1519 PUSHMARK (SP);
1400 PUTBACK; 1520 PUTBACK;
1521 if (ix)
1522 eval_sv (coderef, 0);
1523 else
1401 call_sv (coderef, G_KEEPERR | G_EVAL | G_VOID | G_DISCARD); 1524 call_sv (coderef, G_KEEPERR | G_EVAL | G_VOID | G_DISCARD);
1402 SPAGAIN; 1525 SPAGAIN;
1403 FREETMPS; 1526 FREETMPS;
1404 LEAVE; 1527 LEAVE;
1405 PUTBACK; 1528 PUTBACK;
1406 } 1529 }
1424 CODE: 1547 CODE:
1425 RETVAL = boolSV (coro->flags & ix); 1548 RETVAL = boolSV (coro->flags & ix);
1426 OUTPUT: 1549 OUTPUT:
1427 RETVAL 1550 RETVAL
1428 1551
1552void
1553trace (Coro::State coro, int flags = CC_TRACE | CC_TRACE_SUB)
1554 CODE:
1555 if (flags & CC_TRACE)
1556 {
1557 if (!coro->cctx)
1558 coro->cctx = cctx_new ();
1559 else if (!(coro->cctx->flags & CC_TRACE))
1560 croak ("cannot enable tracing on coroutine with custom stack");
1561
1562 coro->cctx->flags |= flags & (CC_TRACE | CC_TRACE_ALL);
1563 }
1564 else
1565 if (coro->cctx && coro->cctx->flags & CC_TRACE)
1566 {
1567 coro->cctx->flags &= ~(CC_TRACE | CC_TRACE_ALL);
1568 coro->cctx->flags |= CC_NOREUSE;
1569
1570 if (coro->flags & CF_RUNNING)
1571 PL_runops = RUNOPS_DEFAULT;
1572 else
1573 coro->runops = RUNOPS_DEFAULT;
1574 }
1575
1576SV *
1577has_stack (Coro::State coro)
1578 PROTOTYPE: $
1579 CODE:
1580 RETVAL = boolSV (!!coro->cctx);
1581 OUTPUT:
1582 RETVAL
1583
1584int
1585is_traced (Coro::State coro)
1586 PROTOTYPE: $
1587 CODE:
1588 RETVAL = (coro->cctx ? coro->cctx->flags : 0) & CC_TRACE_ALL;
1589 OUTPUT:
1590 RETVAL
1591
1429IV 1592IV
1430rss (Coro::State coro) 1593rss (Coro::State coro)
1431 PROTOTYPE: $ 1594 PROTOTYPE: $
1432 CODE: 1595 CODE:
1433 RETVAL = coro_rss (coro); 1596 RETVAL = coro_rss (coro);
1439 1602
1440BOOT: 1603BOOT:
1441{ 1604{
1442 int i; 1605 int i;
1443 1606
1607 sv_pool_rss = get_sv ("Coro::POOL_RSS" , TRUE);
1608 sv_pool_size = get_sv ("Coro::POOL_SIZE" , TRUE);
1609 av_async_pool = get_av ("Coro::async_pool", TRUE);
1610
1611 coro_current = get_sv ("Coro::current", FALSE);
1612 SvREADONLY_on (coro_current);
1613
1444 coro_stash = gv_stashpv ("Coro", TRUE); 1614 coro_stash = gv_stashpv ("Coro", TRUE);
1445 1615
1446 newCONSTSUB (coro_stash, "PRIO_MAX", newSViv (PRIO_MAX)); 1616 newCONSTSUB (coro_stash, "PRIO_MAX", newSViv (PRIO_MAX));
1447 newCONSTSUB (coro_stash, "PRIO_HIGH", newSViv (PRIO_HIGH)); 1617 newCONSTSUB (coro_stash, "PRIO_HIGH", newSViv (PRIO_HIGH));
1448 newCONSTSUB (coro_stash, "PRIO_NORMAL", newSViv (PRIO_NORMAL)); 1618 newCONSTSUB (coro_stash, "PRIO_NORMAL", newSViv (PRIO_NORMAL));
1449 newCONSTSUB (coro_stash, "PRIO_LOW", newSViv (PRIO_LOW)); 1619 newCONSTSUB (coro_stash, "PRIO_LOW", newSViv (PRIO_LOW));
1450 newCONSTSUB (coro_stash, "PRIO_IDLE", newSViv (PRIO_IDLE)); 1620 newCONSTSUB (coro_stash, "PRIO_IDLE", newSViv (PRIO_IDLE));
1451 newCONSTSUB (coro_stash, "PRIO_MIN", newSViv (PRIO_MIN)); 1621 newCONSTSUB (coro_stash, "PRIO_MIN", newSViv (PRIO_MIN));
1452
1453 coro_current = get_sv ("Coro::current", FALSE);
1454 SvREADONLY_on (coro_current);
1455 1622
1456 for (i = PRIO_MAX - PRIO_MIN + 1; i--; ) 1623 for (i = PRIO_MAX - PRIO_MIN + 1; i--; )
1457 coro_ready[i] = newAV (); 1624 coro_ready[i] = newAV ();
1458 1625
1459 { 1626 {
1517 CODE: 1684 CODE:
1518 RETVAL = coro_nready; 1685 RETVAL = coro_nready;
1519 OUTPUT: 1686 OUTPUT:
1520 RETVAL 1687 RETVAL
1521 1688
1689# for async_pool speedup
1690void
1691_pool_1 (SV *cb)
1692 CODE:
1693{
1694 int i, len;
1695 HV *hv = (HV *)SvRV (coro_current);
1696 AV *defav = GvAV (PL_defgv);
1697 SV *invoke = hv_delete (hv, "_invoke", sizeof ("_invoke") - 1, 0);
1698 AV *invoke_av;
1699
1700 if (!invoke)
1701 croak ("\3terminate\2\n");
1702
1703 hv_store (hv, "desc", sizeof ("desc") - 1,
1704 newSVpvn ("[async_pool]", sizeof ("[async_pool]") - 1), 0);
1705
1706 invoke_av = (AV *)SvRV (invoke);
1707 len = av_len (invoke_av);
1708
1709 sv_setsv (cb, AvARRAY (invoke_av)[0]);
1710
1711 if (len > 0)
1712 {
1713 av_fill (defav, len - 1);
1714 for (i = 0; i < len; ++i)
1715 av_store (defav, i, SvREFCNT_inc (AvARRAY (invoke_av)[i + 1]));
1716 }
1717
1718 SvREFCNT_dec (invoke);
1719}
1720
1721void
1722_pool_2 (SV *cb)
1723 CODE:
1724{
1725 struct coro *coro = SvSTATE (coro_current);
1726
1727 sv_setsv (cb, &PL_sv_undef);
1728
1729 if (coro_rss (coro) > SvIV (sv_pool_rss)
1730 || av_len (av_async_pool) + 1 >= SvIV (sv_pool_size))
1731 croak ("\3terminate\2\n");
1732
1733 av_clear (GvAV (PL_defgv));
1734 hv_store ((HV *)SvRV (coro_current), "desc", sizeof ("desc") - 1,
1735 newSVpvn ("[async_pool idle]", sizeof ("[async_pool idle]") - 1), 0);
1736 coro->save = CORO_SAVE_DEF;
1737 coro->prio = 0;
1738 av_push (av_async_pool, newSVsv (coro_current));
1739}
1740
1741
1522MODULE = Coro::State PACKAGE = Coro::AIO 1742MODULE = Coro::State PACKAGE = Coro::AIO
1523 1743
1524SV * 1744SV *
1525_get_state () 1745_get_state ()
1526 CODE: 1746 CODE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines