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.147 by root, Mon Mar 19 15:50:48 2007 UTC vs.
Revision 1.170 by root, Thu Sep 27 20:14:49 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
129}; 128};
130 129
131static size_t coro_stacksize = CORO_STACKSIZE; 130static size_t coro_stacksize = CORO_STACKSIZE;
132static struct CoroAPI coroapi; 131static struct CoroAPI coroapi;
133static AV *main_mainstack; /* used to differentiate between $main and others */ 132static AV *main_mainstack; /* used to differentiate between $main and others */
133static JMPENV *main_top_env;
134static HV *coro_state_stash, *coro_stash; 134static HV *coro_state_stash, *coro_stash;
135static SV *coro_mortal; /* will be freed after next transfer */ 135static SV *coro_mortal; /* will be freed after next transfer */
136 136
137/* async_pool helper stuff */
138static SV *sv_pool_rss;
139static SV *sv_pool_size;
140static AV *av_async_pool;
141
137static struct coro_cctx *cctx_first; 142static struct coro_cctx *cctx_first;
138static 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};
139 153
140/* this is a structure representing a c-level coroutine */ 154/* this is a structure representing a c-level coroutine */
141typedef struct coro_cctx { 155typedef struct coro_cctx {
142 struct coro_cctx *next; 156 struct coro_cctx *next;
143 157
152 coro_context cctx; 166 coro_context cctx;
153 167
154#if CORO_USE_VALGRIND 168#if CORO_USE_VALGRIND
155 int valgrind_id; 169 int valgrind_id;
156#endif 170#endif
157 char inuse, mapped; 171 unsigned char flags;
158} coro_cctx; 172} coro_cctx;
159 173
160enum { 174enum {
161 CF_RUNNING = 0x0001, /* coroutine is running */ 175 CF_RUNNING = 0x0001, /* coroutine is running */
162 CF_READY = 0x0002, /* coroutine is ready */ 176 CF_READY = 0x0002, /* coroutine is ready */
187# include "state.h" 201# include "state.h"
188#undef VAR 202#undef VAR
189 203
190 /* coro process data */ 204 /* coro process data */
191 int prio; 205 int prio;
206
207 /* linked list */
208 struct coro *next, *prev;
209 HV *hv; /* the perl hash associated with this coro, if any */
192}; 210};
193 211
194typedef struct coro *Coro__State; 212typedef struct coro *Coro__State;
195typedef struct coro *Coro__State_or_hashref; 213typedef struct coro *Coro__State_or_hashref;
196 214
205 223
206/* for Coro.pm */ 224/* for Coro.pm */
207static SV *coro_current; 225static SV *coro_current;
208static AV *coro_ready [PRIO_MAX-PRIO_MIN+1]; 226static AV *coro_ready [PRIO_MAX-PRIO_MIN+1];
209static int coro_nready; 227static int coro_nready;
228static struct coro *coro_first;
210 229
211/** lowlevel stuff **********************************************************/ 230/** lowlevel stuff **********************************************************/
212 231
213static AV * 232static AV *
214coro_clone_padlist (pTHX_ CV *cv) 233coro_clone_padlist (pTHX_ CV *cv)
279 SvMAGIC (cv) \ 298 SvMAGIC (cv) \
280 ? SvMAGIC (cv)->mg_type == PERL_MAGIC_coro \ 299 ? SvMAGIC (cv)->mg_type == PERL_MAGIC_coro \
281 ? SvMAGIC (cv) \ 300 ? SvMAGIC (cv) \
282 : mg_find ((SV *)cv, PERL_MAGIC_coro) \ 301 : mg_find ((SV *)cv, PERL_MAGIC_coro) \
283 : 0 302 : 0
303
304static struct coro *
305SvSTATE_ (pTHX_ SV *coro)
306{
307 HV *stash;
308 MAGIC *mg;
309
310 if (SvROK (coro))
311 coro = SvRV (coro);
312
313 stash = SvSTASH (coro);
314 if (stash != coro_stash && stash != coro_state_stash)
315 {
316 /* very slow, but rare, check */
317 if (!sv_derived_from (sv_2mortal (newRV_inc (coro)), "Coro::State"))
318 croak ("Coro::State object required");
319 }
320
321 mg = CORO_MAGIC (coro);
322 return (struct coro *)mg->mg_ptr;
323}
324
325#define SvSTATE(sv) SvSTATE_ (aTHX_ (sv))
284 326
285/* the next two functions merely cache the padlists */ 327/* the next two functions merely cache the padlists */
286static void 328static void
287get_padlist (pTHX_ CV *cv) 329get_padlist (pTHX_ CV *cv)
288{ 330{
373 CvPADLIST (cv) = (AV *)POPs; 415 CvPADLIST (cv) = (AV *)POPs;
374 } 416 }
375 417
376 PUTBACK; 418 PUTBACK;
377 } 419 }
378 assert (!PL_comppad || AvARRAY (PL_comppad));//D
379} 420}
380 421
381static void 422static void
382save_perl (pTHX_ Coro__State c) 423save_perl (pTHX_ Coro__State c)
383{ 424{
384 assert (!PL_comppad || AvARRAY (PL_comppad));//D
385 { 425 {
386 dSP; 426 dSP;
387 I32 cxix = cxstack_ix; 427 I32 cxix = cxstack_ix;
388 PERL_CONTEXT *ccstk = cxstack; 428 PERL_CONTEXT *ccstk = cxstack;
389 PERL_SI *top_si = PL_curstackinfo; 429 PERL_SI *top_si = PL_curstackinfo;
391 /* 431 /*
392 * the worst thing you can imagine happens first - we have to save 432 * the worst thing you can imagine happens first - we have to save
393 * (and reinitialize) all cv's in the whole callchain :( 433 * (and reinitialize) all cv's in the whole callchain :(
394 */ 434 */
395 435
396 EXTEND (SP, 3 + 1);
397 PUSHs (Nullsv); 436 XPUSHs (Nullsv);
398 /* this loop was inspired by pp_caller */ 437 /* this loop was inspired by pp_caller */
399 for (;;) 438 for (;;)
400 { 439 {
401 while (cxix >= 0) 440 while (cxix >= 0)
402 { 441 {
403 PERL_CONTEXT *cx = &ccstk[cxix--]; 442 PERL_CONTEXT *cx = &ccstk[cxix--];
404 443
405 if (CxTYPE (cx) == CXt_SUB) 444 if (CxTYPE (cx) == CXt_SUB || CxTYPE (cx) == CXt_FORMAT)
406 { 445 {
407 CV *cv = cx->blk_sub.cv; 446 CV *cv = cx->blk_sub.cv;
408 447
409 if (CvDEPTH (cv)) 448 if (CvDEPTH (cv))
410 { 449 {
421 460
422 if (top_si->si_type == PERLSI_MAIN) 461 if (top_si->si_type == PERLSI_MAIN)
423 break; 462 break;
424 463
425 top_si = top_si->si_prev; 464 top_si = top_si->si_prev;
426 ccstk = top_si->si_cxstack; 465 ccstk = top_si->si_cxstack;
427 cxix = top_si->si_cxix; 466 cxix = top_si->si_cxix;
428 } 467 }
429 468
430 PUTBACK; 469 PUTBACK;
431 } 470 }
432 471
451# define coro_init_stacks init_stacks 490# define coro_init_stacks init_stacks
452#else 491#else
453static void 492static void
454coro_init_stacks (pTHX) 493coro_init_stacks (pTHX)
455{ 494{
456 PL_curstackinfo = new_stackinfo(128, 1024/sizeof(PERL_CONTEXT)); 495 PL_curstackinfo = new_stackinfo(64, 6);
457 PL_curstackinfo->si_type = PERLSI_MAIN; 496 PL_curstackinfo->si_type = PERLSI_MAIN;
458 PL_curstack = PL_curstackinfo->si_stack; 497 PL_curstack = PL_curstackinfo->si_stack;
459 PL_mainstack = PL_curstack; /* remember in case we switch stacks */ 498 PL_mainstack = PL_curstack; /* remember in case we switch stacks */
460 499
461 PL_stack_base = AvARRAY(PL_curstack); 500 PL_stack_base = AvARRAY(PL_curstack);
462 PL_stack_sp = PL_stack_base; 501 PL_stack_sp = PL_stack_base;
463 PL_stack_max = PL_stack_base + AvMAX(PL_curstack); 502 PL_stack_max = PL_stack_base + AvMAX(PL_curstack);
464 503
465 New(50,PL_tmps_stack,128,SV*); 504 New(50,PL_tmps_stack,64,SV*);
466 PL_tmps_floor = -1; 505 PL_tmps_floor = -1;
467 PL_tmps_ix = -1; 506 PL_tmps_ix = -1;
468 PL_tmps_max = 128; 507 PL_tmps_max = 64;
469 508
470 New(54,PL_markstack,32,I32); 509 New(54,PL_markstack,16,I32);
471 PL_markstack_ptr = PL_markstack; 510 PL_markstack_ptr = PL_markstack;
472 PL_markstack_max = PL_markstack + 32; 511 PL_markstack_max = PL_markstack + 16;
473 512
474#ifdef SET_MARK_OFFSET 513#ifdef SET_MARK_OFFSET
475 SET_MARK_OFFSET; 514 SET_MARK_OFFSET;
476#endif 515#endif
477 516
478 New(54,PL_scopestack,32,I32); 517 New(54,PL_scopestack,16,I32);
479 PL_scopestack_ix = 0; 518 PL_scopestack_ix = 0;
480 PL_scopestack_max = 32; 519 PL_scopestack_max = 16;
481 520
482 New(54,PL_savestack,64,ANY); 521 New(54,PL_savestack,64,ANY);
483 PL_savestack_ix = 0; 522 PL_savestack_ix = 0;
484 PL_savestack_max = 64; 523 PL_savestack_max = 64;
485 524
486#if !PERL_VERSION_ATLEAST (5,9,0) 525#if !PERL_VERSION_ATLEAST (5,9,0)
487 New(54,PL_retstack,16,OP*); 526 New(54,PL_retstack,4,OP*);
488 PL_retstack_ix = 0; 527 PL_retstack_ix = 0;
489 PL_retstack_max = 16; 528 PL_retstack_max = 4;
490#endif 529#endif
491} 530}
492#endif 531#endif
493 532
494/* 533/*
536#if !PERL_VERSION_ATLEAST (5,9,0) 575#if !PERL_VERSION_ATLEAST (5,9,0)
537 Safefree (PL_retstack); 576 Safefree (PL_retstack);
538#endif 577#endif
539} 578}
540 579
580static size_t
581coro_rss (struct coro *coro)
582{
583 size_t rss = sizeof (coro);
584
585 if (coro->mainstack)
586 {
587 if (coro->flags & CF_RUNNING)
588 {
589 #define VAR(name,type)coro->name = PL_ ## name;
590 # include "state.h"
591 #undef VAR
592 }
593
594 rss += sizeof (coro->curstackinfo);
595 rss += sizeof (struct xpvav) + (1 + AvFILL (coro->curstackinfo->si_stack)) * sizeof (SV *);
596 rss += (coro->curstackinfo->si_cxmax + 1) * sizeof (PERL_CONTEXT);
597 rss += sizeof (struct xpvav) + (1 + AvFILL (coro->curstack)) * sizeof (SV *);
598 rss += coro->tmps_max * sizeof (SV *);
599 rss += (coro->markstack_max - coro->markstack_ptr) * sizeof (I32);
600 rss += coro->scopestack_max * sizeof (I32);
601 rss += coro->savestack_max * sizeof (ANY);
602
603#if !PERL_VERSION_ATLEAST (5,9,0)
604 rss += coro->retstack_max * sizeof (OP *);
605#endif
606 }
607
608 return rss;
609}
610
541/** coroutine stack handling ************************************************/ 611/** coroutine stack handling ************************************************/
542 612
543static void 613static void
544setup_coro (pTHX_ struct coro *coro) 614setup_coro (pTHX_ struct coro *coro)
545{ 615{
546 /* 616 /*
547 * emulate part of the perl startup here. 617 * emulate part of the perl startup here.
548 */ 618 */
549 coro_init_stacks (aTHX); 619 coro_init_stacks (aTHX);
550 620
621 PL_runops = RUNOPS_DEFAULT;
551 PL_curcop = &PL_compiling; 622 PL_curcop = &PL_compiling;
552 PL_in_eval = EVAL_NULL; 623 PL_in_eval = EVAL_NULL;
553 PL_comppad = 0; 624 PL_comppad = 0;
554 PL_curpm = 0; 625 PL_curpm = 0;
555 PL_localizing = 0; 626 PL_localizing = 0;
566 Zero (&myop, 1, LOGOP); 637 Zero (&myop, 1, LOGOP);
567 myop.op_next = Nullop; 638 myop.op_next = Nullop;
568 myop.op_flags = OPf_WANT_VOID; 639 myop.op_flags = OPf_WANT_VOID;
569 640
570 PUSHMARK (SP); 641 PUSHMARK (SP);
571 XPUSHs ((SV *)get_cv ("Coro::State::_coro_init", FALSE)); 642 XPUSHs (av_shift (GvAV (PL_defgv)));
572 PUTBACK; 643 PUTBACK;
573 PL_op = (OP *)&myop; 644 PL_op = (OP *)&myop;
574 PL_op = PL_ppaddr[OP_ENTERSUB](aTHX); 645 PL_op = PL_ppaddr[OP_ENTERSUB](aTHX);
575 SPAGAIN; 646 SPAGAIN;
576 } 647 }
586 SvREFCNT_dec (coro_mortal); 657 SvREFCNT_dec (coro_mortal);
587 coro_mortal = 0; 658 coro_mortal = 0;
588 } 659 }
589} 660}
590 661
662static int
663runops_trace (pTHX)
664{
665 COP *oldcop = 0;
666 int oldcxix = -2;
667 struct coro *coro = SvSTATE (coro_current); /* trace cctx is tied to specific coro */
668 coro_cctx *cctx = coro->cctx;
669
670 while ((PL_op = CALL_FPTR (PL_op->op_ppaddr) (aTHX)))
671 {
672 PERL_ASYNC_CHECK ();
673
674 if (PL_op->op_type == OP_LEAVESUB && cctx->flags & CC_TRACE_SUB)
675 {
676 PERL_CONTEXT *cx = &cxstack[cxstack_ix];
677 SV **bot, **top;
678 AV *av = newAV (); /* return values */
679 SV **cb;
680 runops_proc_t old_runops = PL_runops;
681 dSP;
682 ENTER;
683 SAVETMPS;
684 EXTEND (SP, 3);
685 PL_runops = RUNOPS_DEFAULT;
686
687 GV *gv = CvGV (cx->blk_sub.cv);
688 SV *fullname = sv_2mortal (newSV (0));
689 if (isGV (gv))
690 gv_efullname3 (fullname, gv, 0);
691
692 bot = PL_stack_base + cx->blk_oldsp + 1;
693 top = cx->blk_gimme == G_ARRAY ? SP + 1
694 : cx->blk_gimme == G_SCALAR ? bot + 1
695 : bot;
696
697 while (bot < top)
698 av_push (av, SvREFCNT_inc (*bot++));
699
700 PUSHMARK (SP);
701 PUSHs (&PL_sv_no);
702 PUSHs (fullname);
703 PUSHs (sv_2mortal (newRV_noinc ((SV *)av)));
704 PUTBACK;
705 cb = hv_fetch ((HV *)SvRV (coro_current), "_trace_sub_cb", sizeof ("_trace_sub_cb") - 1, 0);
706 if (cb) call_sv (*cb, G_KEEPERR | G_EVAL | G_VOID | G_DISCARD);
707 SPAGAIN;
708
709 FREETMPS;
710 LEAVE;
711 PL_runops = old_runops;
712 }
713
714 if (oldcop != PL_curcop)
715 {
716 oldcop = PL_curcop;
717
718 if (PL_curcop != &PL_compiling)
719 {
720 SV **cb;
721 runops_proc_t old_runops = PL_runops;
722 dSP;
723 ENTER;
724 SAVETMPS;
725 EXTEND (SP, 3);
726 PL_runops = RUNOPS_DEFAULT;
727
728 if (oldcxix != cxstack_ix && cctx->flags & CC_TRACE_SUB)
729 {
730 PERL_CONTEXT *cx = &cxstack[cxstack_ix];
731
732 if (CxTYPE (cx) == CXt_SUB && oldcxix < cxstack_ix)
733 {
734 GV *gv = CvGV (cx->blk_sub.cv);
735 SV *fullname = sv_2mortal (newSV (0));
736 if (isGV (gv))
737 gv_efullname3 (fullname, gv, 0);
738
739 PUSHMARK (SP);
740 PUSHs (&PL_sv_yes);
741 PUSHs (fullname);
742 PUSHs (cx->blk_sub.hasargs ? sv_2mortal (newRV_inc ((SV *)cx->blk_sub.argarray)) : &PL_sv_undef);
743 PUTBACK;
744 cb = hv_fetch ((HV *)SvRV (coro_current), "_trace_sub_cb", sizeof ("_trace_sub_cb") - 1, 0);
745 if (cb) call_sv (*cb, G_KEEPERR | G_EVAL | G_VOID | G_DISCARD);
746 SPAGAIN;
747 }
748
749 oldcxix = cxstack_ix;
750 }
751
752 if (cctx->flags & CC_TRACE_LINE)
753 {
754 PUSHMARK (SP);
755 PUSHs (sv_2mortal (newSVpv (OutCopFILE (oldcop), 0)));
756 PUSHs (sv_2mortal (newSViv (CopLINE (oldcop))));
757 PUTBACK;
758 cb = hv_fetch ((HV *)SvRV (coro_current), "_trace_line_cb", sizeof ("_trace_line_cb") - 1, 0);
759 if (cb) call_sv (*cb, G_KEEPERR | G_EVAL | G_VOID | G_DISCARD);
760 SPAGAIN;
761 }
762
763 FREETMPS;
764 LEAVE;
765 PL_runops = old_runops;
766 }
767 }
768 }
769
770 TAINT_NOT;
771 return 0;
772}
773
591/* inject a fake call to Coro::State::_cctx_init into the execution */ 774/* inject a fake call to Coro::State::_cctx_init into the execution */
775/* _cctx_init should be careful, as it could be called at almost any time */
776/* during execution of a perl program */
592static void NOINLINE 777static void NOINLINE
593prepare_cctx (pTHX_ coro_cctx *cctx) 778prepare_cctx (pTHX_ coro_cctx *cctx)
594{ 779{
595 dSP; 780 dSP;
596 LOGOP myop; 781 LOGOP myop;
782
783 PL_top_env = &PL_start_env;
784
785 if (cctx->flags & CC_TRACE)
786 PL_runops = runops_trace;
597 787
598 Zero (&myop, 1, LOGOP); 788 Zero (&myop, 1, LOGOP);
599 myop.op_next = PL_op; 789 myop.op_next = PL_op;
600 myop.op_flags = OPf_WANT_VOID | OPf_STACKED; 790 myop.op_flags = OPf_WANT_VOID | OPf_STACKED;
601 791
607 PL_op = (OP *)&myop; 797 PL_op = (OP *)&myop;
608 PL_op = PL_ppaddr[OP_ENTERSUB](aTHX); 798 PL_op = PL_ppaddr[OP_ENTERSUB](aTHX);
609 SPAGAIN; 799 SPAGAIN;
610} 800}
611 801
802/*
803 * this is a _very_ stripped down perl interpreter ;)
804 */
612static void 805static void
613coro_run (void *arg) 806coro_run (void *arg)
614{ 807{
615 dTHX; 808 dTHX;
616 809
617 /* coro_run is the alternative tail of transfer(), so unlock here. */ 810 /* coro_run is the alternative tail of transfer(), so unlock here. */
618 UNLOCK; 811 UNLOCK;
619 812
620 /* 813 /* we now skip the entersub that lead to transfer() */
621 * this is a _very_ stripped down perl interpreter ;) 814 PL_op = PL_op->op_next;
622 */
623 PL_top_env = &PL_start_env;
624 815
625 /* inject call to cctx_init */ 816 /* inject a fake subroutine call to cctx_init */
626 prepare_cctx (aTHX_ (coro_cctx *)arg); 817 prepare_cctx (aTHX_ (coro_cctx *)arg);
627 818
628 /* somebody will hit me for both perl_run and PL_restartop */ 819 /* somebody or something will hit me for both perl_run and PL_restartop */
629 PL_restartop = PL_op; 820 PL_restartop = PL_op;
630 perl_run (PL_curinterp); 821 perl_run (PL_curinterp);
631 822
632 fputs ("FATAL: C coroutine fell over the edge of the world, aborting. Did you call exit in a coroutine?\n", stderr); 823 /*
633 abort (); 824 * If perl-run returns we assume exit() was being called or the coro
825 * fell off the end, which seems to be the only valid (non-bug)
826 * reason for perl_run to return. We try to exit by jumping to the
827 * bootstrap-time "top" top_env, as we cannot restore the "main"
828 * coroutine as Coro has no such concept
829 */
830 PL_top_env = main_top_env;
831 JMPENV_JUMP (2); /* I do not feel well about the hardcoded 2 at all */
634} 832}
635 833
636static coro_cctx * 834static coro_cctx *
637cctx_new () 835cctx_new ()
638{ 836{
655# if CORO_STACKGUARD 853# if CORO_STACKGUARD
656 mprotect (cctx->sptr, CORO_STACKGUARD * PAGESIZE, PROT_NONE); 854 mprotect (cctx->sptr, CORO_STACKGUARD * PAGESIZE, PROT_NONE);
657# endif 855# endif
658 stack_start = CORO_STACKGUARD * PAGESIZE + (char *)cctx->sptr; 856 stack_start = CORO_STACKGUARD * PAGESIZE + (char *)cctx->sptr;
659 stack_size = cctx->ssize - CORO_STACKGUARD * PAGESIZE; 857 stack_size = cctx->ssize - CORO_STACKGUARD * PAGESIZE;
660 cctx->mapped = 1; 858 cctx->flags |= CC_MAPPED;
661 } 859 }
662 else 860 else
663#endif 861#endif
664 { 862 {
665 cctx->ssize = coro_stacksize * (long)sizeof (long); 863 cctx->ssize = coro_stacksize * (long)sizeof (long);
692#if CORO_USE_VALGRIND 890#if CORO_USE_VALGRIND
693 VALGRIND_STACK_DEREGISTER (cctx->valgrind_id); 891 VALGRIND_STACK_DEREGISTER (cctx->valgrind_id);
694#endif 892#endif
695 893
696#if HAVE_MMAP 894#if HAVE_MMAP
697 if (cctx->mapped) 895 if (cctx->flags & CC_MAPPED)
698 munmap (cctx->sptr, cctx->ssize); 896 munmap (cctx->sptr, cctx->ssize);
699 else 897 else
700#endif 898#endif
701 Safefree (cctx->sptr); 899 Safefree (cctx->sptr);
702 900
710 { 908 {
711 coro_cctx *cctx = cctx_first; 909 coro_cctx *cctx = cctx_first;
712 cctx_first = cctx->next; 910 cctx_first = cctx->next;
713 --cctx_idle; 911 --cctx_idle;
714 912
715 if (cctx->ssize >= coro_stacksize) 913 if (cctx->ssize >= coro_stacksize && !(cctx->flags & CC_NOREUSE))
716 return cctx; 914 return cctx;
717 915
718 cctx_destroy (cctx); 916 cctx_destroy (cctx);
719 } 917 }
720 918
721 PL_op = PL_op->op_next;
722 return cctx_new (); 919 return cctx_new ();
723} 920}
724 921
725static void 922static void
726cctx_put (coro_cctx *cctx) 923cctx_put (coro_cctx *cctx)
730 { 927 {
731 coro_cctx *first = cctx_first; 928 coro_cctx *first = cctx_first;
732 cctx_first = first->next; 929 cctx_first = first->next;
733 --cctx_idle; 930 --cctx_idle;
734 931
735 assert (!first->inuse);
736 cctx_destroy (first); 932 cctx_destroy (first);
737 } 933 }
738 934
739 ++cctx_idle; 935 ++cctx_idle;
740 cctx->next = cctx_first; 936 cctx->next = cctx_first;
741 cctx_first = cctx; 937 cctx_first = cctx;
742} 938}
743 939
744/** coroutine switching *****************************************************/ 940/** coroutine switching *****************************************************/
745 941
746/* never call directly, always through the coro_state_transfer global variable */ 942static void NOINLINE
943transfer_check (pTHX_ struct coro *prev, struct coro *next)
944{
945 if (prev != next)
946 {
947 if (!(prev->flags & (CF_RUNNING | CF_NEW)))
948 croak ("Coro::State::transfer called with non-running/new prev Coro::State, but can only transfer from running or new states");
949
950 if (next->flags & CF_RUNNING)
951 croak ("Coro::State::transfer called with running next Coro::State, but can only transfer to inactive states");
952
953 if (next->flags & CF_DESTROYED)
954 croak ("Coro::State::transfer called with destroyed next Coro::State, but can only transfer to inactive states");
955
956 if (PL_lex_state != LEX_NOTPARSING)
957 croak ("Coro::State::transfer called while parsing, but this is not supported");
958 }
959}
960
961/* always use the TRANSFER macro */
747static void NOINLINE 962static void NOINLINE
748transfer (pTHX_ struct coro *prev, struct coro *next) 963transfer (pTHX_ struct coro *prev, struct coro *next)
749{ 964{
750 dSTACKLEVEL; 965 dSTACKLEVEL;
751 966
761 976
762 if (prev->flags & CF_NEW) 977 if (prev->flags & CF_NEW)
763 { 978 {
764 /* create a new empty context */ 979 /* create a new empty context */
765 Newz (0, prev->cctx, 1, coro_cctx); 980 Newz (0, prev->cctx, 1, coro_cctx);
766 prev->cctx->inuse = 1;
767 prev->flags &= ~CF_NEW; 981 prev->flags &= ~CF_NEW;
768 prev->flags |= CF_RUNNING; 982 prev->flags |= CF_RUNNING;
769 } 983 }
770
771 /*TODO: must not croak here */
772 if (!prev->flags & CF_RUNNING)
773 croak ("Coro::State::transfer called with non-running prev Coro::State, but can only transfer from running states");
774
775 if (next->flags & CF_RUNNING)
776 croak ("Coro::State::transfer called with running next Coro::State, but can only transfer to inactive states");
777
778 if (next->flags & CF_DESTROYED)
779 croak ("Coro::State::transfer called with destroyed next Coro::State, but can only transfer to inactive states");
780 984
781 prev->flags &= ~CF_RUNNING; 985 prev->flags &= ~CF_RUNNING;
782 next->flags |= CF_RUNNING; 986 next->flags |= CF_RUNNING;
783 987
784 LOCK; 988 LOCK;
789 next->flags &= ~CF_NEW; 993 next->flags &= ~CF_NEW;
790 /* first get rid of the old state */ 994 /* first get rid of the old state */
791 save_perl (aTHX_ prev); 995 save_perl (aTHX_ prev);
792 /* setup coroutine call */ 996 /* setup coroutine call */
793 setup_coro (aTHX_ next); 997 setup_coro (aTHX_ next);
794 /* need a new stack */
795 assert (!next->cctx);
796 } 998 }
797 else 999 else
798 { 1000 {
799 /* coroutine already started */ 1001 /* coroutine already started */
800 save_perl (aTHX_ prev); 1002 save_perl (aTHX_ prev);
802 } 1004 }
803 1005
804 prev__cctx = prev->cctx; 1006 prev__cctx = prev->cctx;
805 1007
806 /* possibly "free" the cctx */ 1008 /* possibly "free" the cctx */
807 if (prev__cctx->idle_sp == STACKLEVEL) 1009 if (prev__cctx->idle_sp == STACKLEVEL && !(prev__cctx->flags & CC_TRACE))
808 { 1010 {
809 /* I assume that STACKLEVEL is a stronger indicator than PL_top_env changes */ 1011 /* I assume that STACKLEVEL is a stronger indicator than PL_top_env changes */
810 assert (("ERROR: current top_env must equal previous top_env", PL_top_env == prev__cctx->idle_te)); 1012 assert (("ERROR: current top_env must equal previous top_env", PL_top_env == prev__cctx->idle_te));
811 1013
812 prev->cctx = 0; 1014 prev->cctx = 0;
813 1015
814 cctx_put (prev__cctx); 1016 cctx_put (prev__cctx);
815 prev__cctx->inuse = 0;
816 } 1017 }
817 1018
818 if (!next->cctx) 1019 if (!next->cctx)
819 {
820 next->cctx = cctx_get (aTHX); 1020 next->cctx = cctx_get (aTHX);
821 assert (!next->cctx->inuse);
822 next->cctx->inuse = 1;
823 }
824 1021
825 if (prev__cctx != next->cctx) 1022 if (prev__cctx != next->cctx)
826 { 1023 {
827 prev__cctx->top_env = PL_top_env; 1024 prev__cctx->top_env = PL_top_env;
828 PL_top_env = next->cctx->top_env; 1025 PL_top_env = next->cctx->top_env;
838{ 1035{
839 struct coro *prev, *next; 1036 struct coro *prev, *next;
840}; 1037};
841 1038
842#define TRANSFER(ta) transfer (aTHX_ (ta).prev, (ta).next) 1039#define TRANSFER(ta) transfer (aTHX_ (ta).prev, (ta).next)
1040#define TRANSFER_CHECK(ta) transfer_check (aTHX_ (ta).prev, (ta).next)
843 1041
844/** high level stuff ********************************************************/ 1042/** high level stuff ********************************************************/
845 1043
846static int 1044static int
847coro_state_destroy (pTHX_ struct coro *coro) 1045coro_state_destroy (pTHX_ struct coro *coro)
867 struct coro temp; 1065 struct coro temp;
868 1066
869 assert (!(coro->flags & CF_RUNNING)); 1067 assert (!(coro->flags & CF_RUNNING));
870 1068
871 Zero (&temp, 1, struct coro); 1069 Zero (&temp, 1, struct coro);
872 temp.save = CORO_SAVE_DEF; 1070 temp.save = CORO_SAVE_ALL;
873 1071
874 if (coro->flags & CF_RUNNING) 1072 if (coro->flags & CF_RUNNING)
875 croak ("FATAL: tried to destroy currently running coroutine"); 1073 croak ("FATAL: tried to destroy currently running coroutine");
876 1074
877 save_perl (aTHX_ &temp); 1075 save_perl (aTHX_ &temp);
885 } 1083 }
886 1084
887 cctx_destroy (coro->cctx); 1085 cctx_destroy (coro->cctx);
888 SvREFCNT_dec (coro->args); 1086 SvREFCNT_dec (coro->args);
889 1087
1088 if (coro->next) coro->next->prev = coro->prev;
1089 if (coro->prev) coro->prev->next = coro->next;
1090 if (coro == coro_first) coro_first = coro->next;
1091
890 return 1; 1092 return 1;
891} 1093}
892 1094
893static int 1095static int
894coro_state_free (pTHX_ SV *sv, MAGIC *mg) 1096coro_state_free (pTHX_ SV *sv, MAGIC *mg)
895{ 1097{
896 struct coro *coro = (struct coro *)mg->mg_ptr; 1098 struct coro *coro = (struct coro *)mg->mg_ptr;
897 mg->mg_ptr = 0; 1099 mg->mg_ptr = 0;
1100
1101 coro->hv = 0;
898 1102
899 if (--coro->refcnt < 0) 1103 if (--coro->refcnt < 0)
900 { 1104 {
901 coro_state_destroy (aTHX_ coro); 1105 coro_state_destroy (aTHX_ coro);
902 Safefree (coro); 1106 Safefree (coro);
924#else 1128#else
925# define MGf_DUP 0 1129# define MGf_DUP 0
926#endif 1130#endif
927}; 1131};
928 1132
929static struct coro *
930SvSTATE_ (pTHX_ SV *coro)
931{
932 HV *stash;
933 MAGIC *mg;
934
935 if (SvROK (coro))
936 coro = SvRV (coro);
937
938 stash = SvSTASH (coro);
939 if (stash != coro_stash && stash != coro_state_stash)
940 {
941 /* very slow, but rare, check */
942 if (!sv_derived_from (sv_2mortal (newRV_inc (coro)), "Coro::State"))
943 croak ("Coro::State object required");
944 }
945
946 mg = CORO_MAGIC (coro);
947 return (struct coro *)mg->mg_ptr;
948}
949
950#define SvSTATE(sv) SvSTATE_ (aTHX_ (sv))
951
952static void 1133static void
953prepare_transfer (pTHX_ struct transfer_args *ta, SV *prev_sv, SV *next_sv) 1134prepare_transfer (pTHX_ struct transfer_args *ta, SV *prev_sv, SV *next_sv)
954{ 1135{
955 ta->prev = SvSTATE (prev_sv); 1136 ta->prev = SvSTATE (prev_sv);
956 ta->next = SvSTATE (next_sv); 1137 ta->next = SvSTATE (next_sv);
1138 TRANSFER_CHECK (*ta);
957} 1139}
958 1140
959static void 1141static void
960api_transfer (SV *prev_sv, SV *next_sv) 1142api_transfer (SV *prev_sv, SV *next_sv)
961{ 1143{
1078 break; 1260 break;
1079 } 1261 }
1080 1262
1081 /* free this only after the transfer */ 1263 /* free this only after the transfer */
1082 prev_sv = SvRV (coro_current); 1264 prev_sv = SvRV (coro_current);
1083 SvRV_set (coro_current, next_sv);
1084 ta->prev = SvSTATE (prev_sv); 1265 ta->prev = SvSTATE (prev_sv);
1085 1266 TRANSFER_CHECK (*ta);
1086 assert (ta->next->flags & CF_READY); 1267 assert (ta->next->flags & CF_READY);
1087 ta->next->flags &= ~CF_READY; 1268 ta->next->flags &= ~CF_READY;
1269 SvRV_set (coro_current, next_sv);
1088 1270
1089 LOCK; 1271 LOCK;
1090 free_coro_mortal (aTHX); 1272 free_coro_mortal (aTHX);
1091 coro_mortal = prev_sv; 1273 coro_mortal = prev_sv;
1092 UNLOCK; 1274 UNLOCK;
1165 MUTEX_INIT (&coro_mutex); 1347 MUTEX_INIT (&coro_mutex);
1166#endif 1348#endif
1167 BOOT_PAGESIZE; 1349 BOOT_PAGESIZE;
1168 1350
1169 coro_state_stash = gv_stashpv ("Coro::State", TRUE); 1351 coro_state_stash = gv_stashpv ("Coro::State", TRUE);
1352
1353 newCONSTSUB (coro_state_stash, "CC_TRACE" , newSViv (CC_TRACE));
1354 newCONSTSUB (coro_state_stash, "CC_TRACE_SUB" , newSViv (CC_TRACE_SUB));
1355 newCONSTSUB (coro_state_stash, "CC_TRACE_LINE", newSViv (CC_TRACE_LINE));
1356 newCONSTSUB (coro_state_stash, "CC_TRACE_ALL" , newSViv (CC_TRACE_ALL));
1170 1357
1171 newCONSTSUB (coro_state_stash, "SAVE_DEFAV", newSViv (CORO_SAVE_DEFAV)); 1358 newCONSTSUB (coro_state_stash, "SAVE_DEFAV", newSViv (CORO_SAVE_DEFAV));
1172 newCONSTSUB (coro_state_stash, "SAVE_DEFSV", newSViv (CORO_SAVE_DEFSV)); 1359 newCONSTSUB (coro_state_stash, "SAVE_DEFSV", newSViv (CORO_SAVE_DEFSV));
1173 newCONSTSUB (coro_state_stash, "SAVE_ERRSV", newSViv (CORO_SAVE_ERRSV)); 1360 newCONSTSUB (coro_state_stash, "SAVE_ERRSV", newSViv (CORO_SAVE_ERRSV));
1174 newCONSTSUB (coro_state_stash, "SAVE_IRSSV", newSViv (CORO_SAVE_IRSSV)); 1361 newCONSTSUB (coro_state_stash, "SAVE_IRSSV", newSViv (CORO_SAVE_IRSSV));
1175 newCONSTSUB (coro_state_stash, "SAVE_DEFFH", newSViv (CORO_SAVE_DEFFH)); 1362 newCONSTSUB (coro_state_stash, "SAVE_DEFFH", newSViv (CORO_SAVE_DEFFH));
1176 newCONSTSUB (coro_state_stash, "SAVE_DEF", newSViv (CORO_SAVE_DEF)); 1363 newCONSTSUB (coro_state_stash, "SAVE_DEF", newSViv (CORO_SAVE_DEF));
1177 newCONSTSUB (coro_state_stash, "SAVE_ALL", newSViv (CORO_SAVE_ALL)); 1364 newCONSTSUB (coro_state_stash, "SAVE_ALL", newSViv (CORO_SAVE_ALL));
1178 1365
1179 main_mainstack = PL_mainstack; 1366 main_mainstack = PL_mainstack;
1367 main_top_env = PL_top_env;
1368
1369 while (main_top_env->je_prev)
1370 main_top_env = main_top_env->je_prev;
1180 1371
1181 coroapi.ver = CORO_API_VERSION; 1372 coroapi.ver = CORO_API_VERSION;
1182 coroapi.transfer = api_transfer; 1373 coroapi.transfer = api_transfer;
1183 1374
1184 assert (("PRIO_NORMAL must be 0", !PRIO_NORMAL)); 1375 assert (("PRIO_NORMAL must be 0", !PRIO_NORMAL));
1195 Newz (0, coro, 1, struct coro); 1386 Newz (0, coro, 1, struct coro);
1196 coro->args = newAV (); 1387 coro->args = newAV ();
1197 coro->save = CORO_SAVE_DEF; 1388 coro->save = CORO_SAVE_DEF;
1198 coro->flags = CF_NEW; 1389 coro->flags = CF_NEW;
1199 1390
1391 if (coro_first) coro_first->prev = coro;
1392 coro->next = coro_first;
1393 coro_first = coro;
1394
1200 hv = newHV (); 1395 coro->hv = hv = newHV ();
1201 sv_magicext ((SV *)hv, 0, PERL_MAGIC_ext, &coro_state_vtbl, (char *)coro, 0)->mg_flags |= MGf_DUP; 1396 sv_magicext ((SV *)hv, 0, PERL_MAGIC_ext, &coro_state_vtbl, (char *)coro, 0)->mg_flags |= MGf_DUP;
1202 RETVAL = sv_bless (newRV_noinc ((SV *)hv), gv_stashpv (klass, 1)); 1397 RETVAL = sv_bless (newRV_noinc ((SV *)hv), gv_stashpv (klass, 1));
1203 1398
1204 for (i = 1; i < items; i++) 1399 for (i = 1; i < items; i++)
1205 av_push (coro->args, newSVsv (ST (i))); 1400 av_push (coro->args, newSVsv (ST (i)));
1307 CODE: 1502 CODE:
1308 RETVAL = cctx_idle; 1503 RETVAL = cctx_idle;
1309 OUTPUT: 1504 OUTPUT:
1310 RETVAL 1505 RETVAL
1311 1506
1507void
1508list ()
1509 PPCODE:
1510{
1511 struct coro *coro;
1512 for (coro = coro_first; coro; coro = coro->next)
1513 if (coro->hv)
1514 XPUSHs (sv_2mortal (newRV_inc ((SV *)coro->hv)));
1515}
1516
1517void
1518call (Coro::State coro, SV *coderef)
1519 ALIAS:
1520 eval = 1
1521 CODE:
1522{
1523 if (coro->mainstack)
1524 {
1525 struct coro temp;
1526 Zero (&temp, 1, struct coro);
1527 temp.save = CORO_SAVE_ALL;
1528
1529 if (!(coro->flags & CF_RUNNING))
1530 {
1531 save_perl (aTHX_ &temp);
1532 load_perl (aTHX_ coro);
1533 }
1534
1535 {
1536 dSP;
1537 ENTER;
1538 SAVETMPS;
1539 PUSHMARK (SP);
1540 PUTBACK;
1541 if (ix)
1542 eval_sv (coderef, 0);
1543 else
1544 call_sv (coderef, G_KEEPERR | G_EVAL | G_VOID | G_DISCARD);
1545 SPAGAIN;
1546 FREETMPS;
1547 LEAVE;
1548 PUTBACK;
1549 }
1550
1551 if (!(coro->flags & CF_RUNNING))
1552 {
1553 save_perl (aTHX_ coro);
1554 load_perl (aTHX_ &temp);
1555 }
1556 }
1557}
1558
1559SV *
1560is_ready (Coro::State coro)
1561 PROTOTYPE: $
1562 ALIAS:
1563 is_ready = CF_READY
1564 is_running = CF_RUNNING
1565 is_new = CF_NEW
1566 is_destroyed = CF_DESTROYED
1567 CODE:
1568 RETVAL = boolSV (coro->flags & ix);
1569 OUTPUT:
1570 RETVAL
1571
1572void
1573trace (Coro::State coro, int flags = CC_TRACE | CC_TRACE_SUB)
1574 CODE:
1575 if (flags & CC_TRACE)
1576 {
1577 if (!coro->cctx)
1578 coro->cctx = cctx_new ();
1579 else if (!(coro->cctx->flags & CC_TRACE))
1580 croak ("cannot enable tracing on coroutine with custom stack");
1581
1582 coro->cctx->flags |= flags & (CC_TRACE | CC_TRACE_ALL);
1583 }
1584 else
1585 if (coro->cctx && coro->cctx->flags & CC_TRACE)
1586 {
1587 coro->cctx->flags &= ~(CC_TRACE | CC_TRACE_ALL);
1588 coro->cctx->flags |= CC_NOREUSE;
1589
1590 if (coro->flags & CF_RUNNING)
1591 PL_runops = RUNOPS_DEFAULT;
1592 else
1593 coro->runops = RUNOPS_DEFAULT;
1594 }
1595
1596SV *
1597has_stack (Coro::State coro)
1598 PROTOTYPE: $
1599 CODE:
1600 RETVAL = boolSV (!!coro->cctx);
1601 OUTPUT:
1602 RETVAL
1603
1604int
1605is_traced (Coro::State coro)
1606 PROTOTYPE: $
1607 CODE:
1608 RETVAL = (coro->cctx ? coro->cctx->flags : 0) & CC_TRACE_ALL;
1609 OUTPUT:
1610 RETVAL
1611
1612IV
1613rss (Coro::State coro)
1614 PROTOTYPE: $
1615 CODE:
1616 RETVAL = coro_rss (coro);
1617 OUTPUT:
1618 RETVAL
1619
1620
1312MODULE = Coro::State PACKAGE = Coro 1621MODULE = Coro::State PACKAGE = Coro
1313 1622
1314BOOT: 1623BOOT:
1315{ 1624{
1316 int i; 1625 int i;
1626
1627 sv_pool_rss = get_sv ("Coro::POOL_RSS" , TRUE);
1628 sv_pool_size = get_sv ("Coro::POOL_SIZE" , TRUE);
1629 av_async_pool = get_av ("Coro::async_pool", TRUE);
1630
1631 coro_current = get_sv ("Coro::current", FALSE);
1632 SvREADONLY_on (coro_current);
1317 1633
1318 coro_stash = gv_stashpv ("Coro", TRUE); 1634 coro_stash = gv_stashpv ("Coro", TRUE);
1319 1635
1320 newCONSTSUB (coro_stash, "PRIO_MAX", newSViv (PRIO_MAX)); 1636 newCONSTSUB (coro_stash, "PRIO_MAX", newSViv (PRIO_MAX));
1321 newCONSTSUB (coro_stash, "PRIO_HIGH", newSViv (PRIO_HIGH)); 1637 newCONSTSUB (coro_stash, "PRIO_HIGH", newSViv (PRIO_HIGH));
1322 newCONSTSUB (coro_stash, "PRIO_NORMAL", newSViv (PRIO_NORMAL)); 1638 newCONSTSUB (coro_stash, "PRIO_NORMAL", newSViv (PRIO_NORMAL));
1323 newCONSTSUB (coro_stash, "PRIO_LOW", newSViv (PRIO_LOW)); 1639 newCONSTSUB (coro_stash, "PRIO_LOW", newSViv (PRIO_LOW));
1324 newCONSTSUB (coro_stash, "PRIO_IDLE", newSViv (PRIO_IDLE)); 1640 newCONSTSUB (coro_stash, "PRIO_IDLE", newSViv (PRIO_IDLE));
1325 newCONSTSUB (coro_stash, "PRIO_MIN", newSViv (PRIO_MIN)); 1641 newCONSTSUB (coro_stash, "PRIO_MIN", newSViv (PRIO_MIN));
1326
1327 coro_current = get_sv ("Coro::current", FALSE);
1328 SvREADONLY_on (coro_current);
1329 1642
1330 for (i = PRIO_MAX - PRIO_MIN + 1; i--; ) 1643 for (i = PRIO_MAX - PRIO_MIN + 1; i--; )
1331 coro_ready[i] = newAV (); 1644 coro_ready[i] = newAV ();
1332 1645
1333 { 1646 {
1383 CODE: 1696 CODE:
1384 RETVAL = boolSV (api_ready (self)); 1697 RETVAL = boolSV (api_ready (self));
1385 OUTPUT: 1698 OUTPUT:
1386 RETVAL 1699 RETVAL
1387 1700
1388SV *
1389is_ready (SV *self)
1390 PROTOTYPE: $
1391 CODE:
1392 RETVAL = boolSV (api_is_ready (self));
1393 OUTPUT:
1394 RETVAL
1395
1396int 1701int
1397nready (...) 1702nready (...)
1398 PROTOTYPE: 1703 PROTOTYPE:
1399 CODE: 1704 CODE:
1400 RETVAL = coro_nready; 1705 RETVAL = coro_nready;
1401 OUTPUT: 1706 OUTPUT:
1402 RETVAL 1707 RETVAL
1403 1708
1709# for async_pool speedup
1710void
1711_pool_1 (SV *cb)
1712 CODE:
1713{
1714 int i, len;
1715 HV *hv = (HV *)SvRV (coro_current);
1716 AV *defav = GvAV (PL_defgv);
1717 SV *invoke = hv_delete (hv, "_invoke", sizeof ("_invoke") - 1, 0);
1718 AV *invoke_av;
1719
1720 if (!invoke)
1721 croak ("\3terminate\2\n");
1722
1723 hv_store (hv, "desc", sizeof ("desc") - 1,
1724 newSVpvn ("[async_pool]", sizeof ("[async_pool]") - 1), 0);
1725
1726 invoke_av = (AV *)SvRV (invoke);
1727 len = av_len (invoke_av);
1728
1729 sv_setsv (cb, AvARRAY (invoke_av)[0]);
1730
1731 if (len > 0)
1732 {
1733 av_fill (defav, len - 1);
1734 for (i = 0; i < len; ++i)
1735 av_store (defav, i, SvREFCNT_inc (AvARRAY (invoke_av)[i + 1]));
1736 }
1737
1738 SvREFCNT_dec (invoke);
1739}
1740
1741void
1742_pool_2 (SV *cb)
1743 CODE:
1744{
1745 struct coro *coro = SvSTATE (coro_current);
1746
1747 sv_setsv (cb, &PL_sv_undef);
1748
1749 if (coro_rss (coro) > SvIV (sv_pool_rss)
1750 || av_len (av_async_pool) + 1 >= SvIV (sv_pool_size))
1751 croak ("\3terminate\2\n");
1752
1753 av_clear (GvAV (PL_defgv));
1754 hv_store ((HV *)SvRV (coro_current), "desc", sizeof ("desc") - 1,
1755 newSVpvn ("[async_pool idle]", sizeof ("[async_pool idle]") - 1), 0);
1756 coro->save = CORO_SAVE_DEF;
1757 coro->prio = 0;
1758 av_push (av_async_pool, newSVsv (coro_current));
1759}
1760
1761
1404MODULE = Coro::State PACKAGE = Coro::AIO 1762MODULE = Coro::State PACKAGE = Coro::AIO
1405 1763
1406SV * 1764SV *
1407_get_state () 1765_get_state ()
1408 CODE: 1766 CODE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines