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.24 by root, Tue Aug 14 14:56:22 2001 UTC vs.
Revision 1.25 by root, Wed Aug 15 03:24:07 2001 UTC

778#define PRIO_MIN -4 778#define PRIO_MIN -4
779 779
780/* for Coro.pm */ 780/* for Coro.pm */
781static GV *coro_current, *coro_idle; 781static GV *coro_current, *coro_idle;
782static AV *coro_ready[PRIO_MAX-PRIO_MIN+1]; 782static AV *coro_ready[PRIO_MAX-PRIO_MIN+1];
783static int coro_nready;
783 784
784static void 785static void
785coro_enq (SV *sv) 786coro_enq (SV *sv)
786{ 787{
787 if (SvROK (sv)) 788 if (SvROK (sv))
795 prio = prio > PRIO_MAX ? PRIO_MAX 796 prio = prio > PRIO_MAX ? PRIO_MAX
796 : prio < PRIO_MIN ? PRIO_MIN 797 : prio < PRIO_MIN ? PRIO_MIN
797 : prio; 798 : prio;
798 799
799 av_push (coro_ready [prio - PRIO_MIN], sv); 800 av_push (coro_ready [prio - PRIO_MIN], sv);
801 coro_nready++;
800 802
801 return; 803 return;
802 } 804 }
803 } 805 }
804 806
814 if (min_prio < 0) 816 if (min_prio < 0)
815 min_prio = 0; 817 min_prio = 0;
816 818
817 for (prio = PRIO_MAX - PRIO_MIN + 1; --prio >= min_prio; ) 819 for (prio = PRIO_MAX - PRIO_MIN + 1; --prio >= min_prio; )
818 if (av_len (coro_ready[prio]) >= 0) 820 if (av_len (coro_ready[prio]) >= 0)
821 {
822 coro_nready--;
819 return av_shift (coro_ready[prio]); 823 return av_shift (coro_ready[prio]);
824 }
820 825
821 return 0; 826 return 0;
822} 827}
823 828
824static void 829static void
875 880
876 coroapi.ver = CORO_API_VERSION - 1; 881 coroapi.ver = CORO_API_VERSION - 1;
877 coroapi.transfer = api_transfer; 882 coroapi.transfer = api_transfer;
878 coroapi.schedule = api_schedule; 883 coroapi.schedule = api_schedule;
879 coroapi.ready = api_ready; 884 coroapi.ready = api_ready;
885 coroapi.nready = &coro_nready;
880 886
881 GCoroAPI = &coroapi; 887 GCoroAPI = &coroapi;
882 sv_setiv(sv, (IV)&coroapi); 888 sv_setiv(sv, (IV)&coroapi);
883 SvREADONLY_on(sv); 889 SvREADONLY_on(sv);
884 } 890 }
1015ready(self) 1021ready(self)
1016 SV * self 1022 SV * self
1017 CODE: 1023 CODE:
1018 api_ready (self); 1024 api_ready (self);
1019 1025
1026int
1027nready(...)
1028 PROTOTYPE:
1029 CODE:
1030 RETVAL = coro_nready;
1031 OUTPUT:
1032 RETVAL
1033
1020void 1034void
1021schedule(...) 1035schedule(...)
1036 PROTOTYPE:
1022 ALIAS: 1037 ALIAS:
1023 cede = 1 1038 cede = 1
1024 CODE: 1039 CODE:
1025 api_schedule (ix); 1040 api_schedule (ix);
1026 1041

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines