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.114 by root, Thu Nov 30 21:22:45 2006 UTC vs.
Revision 1.115 by root, Fri Dec 1 13:36:08 2006 UTC

7#include "patchlevel.h" 7#include "patchlevel.h"
8 8
9#if USE_VALGRIND 9#if USE_VALGRIND
10# include <valgrind/valgrind.h> 10# include <valgrind/valgrind.h>
11#endif 11#endif
12
13/* the maximum number of idle cctx that will be pooled */
14#define MAX_IDLE_CCTX 8
12 15
13#define PERL_VERSION_ATLEAST(a,b,c) \ 16#define PERL_VERSION_ATLEAST(a,b,c) \
14 (PERL_REVISION > (a) \ 17 (PERL_REVISION > (a) \
15 || (PERL_REVISION == (a) \ 18 || (PERL_REVISION == (a) \
16 && (PERL_VERSION > (b) \ 19 && (PERL_VERSION > (b) \
613 616
614 return cctx; 617 return cctx;
615} 618}
616 619
617static void 620static void
618cctx_free (coro_cctx *cctx) 621cctx_destroy (coro_cctx *cctx)
619{ 622{
620 if (!cctx) 623 if (!cctx)
621 return; 624 return;
622 625
623 --cctx_count; 626 --cctx_count;
640{ 643{
641 coro_cctx *cctx; 644 coro_cctx *cctx;
642 645
643 if (cctx_first) 646 if (cctx_first)
644 { 647 {
645 --cctx_idle;
646 cctx = cctx_first; 648 cctx = cctx_first;
647 cctx_first = cctx->next; 649 cctx_first = cctx->next;
650 --cctx_idle;
648 } 651 }
649 else 652 else
650 { 653 {
651 cctx = cctx_new (); 654 cctx = cctx_new ();
652 PL_op = PL_op->op_next; 655 PL_op = PL_op->op_next;
656} 659}
657 660
658static void 661static void
659cctx_put (coro_cctx *cctx) 662cctx_put (coro_cctx *cctx)
660{ 663{
664 /* free another cctx if overlimit */
665 if (cctx_idle >= MAX_IDLE_CCTX)
666 {
667 coro_cctx *first = cctx_first;
668 cctx_first = first->next;
669 --cctx_idle;
670
671 assert (!first->inuse);
672 cctx_destroy (first);
673 }
674
661 ++cctx_idle; 675 ++cctx_idle;
662 cctx->next = cctx_first; 676 cctx->next = cctx_first;
663 cctx_first = cctx; 677 cctx_first = cctx;
664} 678}
665 679
775 LOAD ((&temp)); /* this will get rid of defsv etc.. */ 789 LOAD ((&temp)); /* this will get rid of defsv etc.. */
776 790
777 coro->mainstack = 0; 791 coro->mainstack = 0;
778 } 792 }
779 793
780 cctx_free (coro->cctx); 794 cctx_destroy (coro->cctx);
781 SvREFCNT_dec (coro->args); 795 SvREFCNT_dec (coro->args);
782 Safefree (coro); 796 Safefree (coro);
783} 797}
784 798
785static int 799static int

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines