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.292 by root, Tue Nov 18 06:09:35 2008 UTC vs.
Revision 1.299 by root, Wed Nov 19 00:06:55 2008 UTC

120#endif 120#endif
121 121
122/* The next macros try to return the current stack pointer, in an as 122/* The next macros try to return the current stack pointer, in an as
123 * portable way as possible. */ 123 * portable way as possible. */
124#if __GNUC__ >= 4 124#if __GNUC__ >= 4
125# define dSTACKLEVEL int stacklevel_dummy
125# define dSTACKLEVEL void *stacklevel = __builtin_frame_address (0) 126# define STACKLEVEL __builtin_frame_address (0)
126#else 127#else
127# define dSTACKLEVEL volatile void *stacklevel = (volatile void *)&stacklevel 128# define dSTACKLEVEL volatile void *stacklevel
129# define STACKLEVEL ((void *)&stacklevel)
128#endif 130#endif
129 131
130#define IN_DESTRUCT (PL_main_cv == Nullcv) 132#define IN_DESTRUCT (PL_main_cv == Nullcv)
131 133
132#if __GNUC__ >= 3 134#if __GNUC__ >= 3
143#define expect_true(expr) expect ((expr) != 0, 1) 145#define expect_true(expr) expect ((expr) != 0, 1)
144 146
145#define NOINLINE attribute ((noinline)) 147#define NOINLINE attribute ((noinline))
146 148
147#include "CoroAPI.h" 149#include "CoroAPI.h"
150#define GCoroAPI (&coroapi) /* very sneaky */
148 151
149#ifdef USE_ITHREADS 152#ifdef USE_ITHREADS
150# if CORO_PTHREAD 153# if CORO_PTHREAD
151static void *coro_thx; 154static void *coro_thx;
152# endif 155# endif
254 /* statistics */ 257 /* statistics */
255 int usecount; /* number of transfers to this coro */ 258 int usecount; /* number of transfers to this coro */
256 259
257 /* coro process data */ 260 /* coro process data */
258 int prio; 261 int prio;
259 SV *throw; /* exception to be thrown */ 262 SV *except; /* exception to be thrown */
260 263
261 /* async_pool */ 264 /* async_pool */
262 SV *saved_deffh; 265 SV *saved_deffh;
263 266
264 /* linked list */ 267 /* linked list */
270 273
271/* the following variables are effectively part of the perl context */ 274/* the following variables are effectively part of the perl context */
272/* and get copied between struct coro and these variables */ 275/* and get copied between struct coro and these variables */
273/* the mainr easonw e don't support windows process emulation */ 276/* the mainr easonw e don't support windows process emulation */
274static struct CoroSLF slf_frame; /* the current slf frame */ 277static struct CoroSLF slf_frame; /* the current slf frame */
275static SV *coro_throw;
276 278
277/** Coro ********************************************************************/ 279/** Coro ********************************************************************/
278 280
279#define PRIO_MAX 3 281#define PRIO_MAX 3
280#define PRIO_HIGH 1 282#define PRIO_HIGH 1
509 511
510 PUTBACK; 512 PUTBACK;
511 } 513 }
512 514
513 slf_frame = c->slf_frame; 515 slf_frame = c->slf_frame;
514 coro_throw = c->throw; 516 CORO_THROW = c->except;
515} 517}
516 518
517static void 519static void
518save_perl (pTHX_ Coro__State c) 520save_perl (pTHX_ Coro__State c)
519{ 521{
520 c->throw = coro_throw; 522 c->except = CORO_THROW;
521 c->slf_frame = slf_frame; 523 c->slf_frame = slf_frame;
522 524
523 { 525 {
524 dSP; 526 dSP;
525 I32 cxix = cxstack_ix; 527 I32 cxix = cxstack_ix;
857 { 859 {
858 dSP; 860 dSP;
859 UNOP myop; 861 UNOP myop;
860 862
861 Zero (&myop, 1, UNOP); 863 Zero (&myop, 1, UNOP);
862 myop.op_next = Nullop; 864 myop.op_next = Nullop;
863 myop.op_flags = OPf_WANT_VOID; 865 myop.op_flags = OPf_WANT_VOID;
864 866
865 PUSHMARK (SP); 867 PUSHMARK (SP);
866 XPUSHs (sv_2mortal (av_shift (GvAV (PL_defgv)))); 868 XPUSHs (sv_2mortal (av_shift (GvAV (PL_defgv))));
867 PUTBACK; 869 PUTBACK;
875 */ 877 */
876 slf_frame.prepare = prepare_nop; /* provide a nop function for an eventual pp_slf */ 878 slf_frame.prepare = prepare_nop; /* provide a nop function for an eventual pp_slf */
877 slf_frame.check = slf_check_nop; /* signal pp_slf to not repeat */ 879 slf_frame.check = slf_check_nop; /* signal pp_slf to not repeat */
878 880
879 /* and we have to provide the pp_slf op in any case, so pp_slf can skip it */ 881 /* and we have to provide the pp_slf op in any case, so pp_slf can skip it */
882 coro_setup_op.op_next = PL_op;
880 coro_setup_op.op_type = OP_CUSTOM; 883 coro_setup_op.op_type = OP_CUSTOM;
881 coro_setup_op.op_ppaddr = pp_slf; 884 coro_setup_op.op_ppaddr = pp_slf;
882 coro_setup_op.op_next = PL_op; 885 /* no flags required, as an init function won't be called */
883 886
884 PL_op = (OP *)&coro_setup_op; 887 PL_op = (OP *)&coro_setup_op;
885 888
886 /* copy throw, in case it was set before coro_setup */ 889 /* copy throw, in case it was set before coro_setup */
887 coro_throw = coro->throw; 890 CORO_THROW = coro->except;
888} 891}
889 892
890static void 893static void
891coro_destruct (pTHX_ struct coro *coro) 894coro_destruct (pTHX_ struct coro *coro)
892{ 895{
916 919
917 SvREFCNT_dec (PL_diehook); 920 SvREFCNT_dec (PL_diehook);
918 SvREFCNT_dec (PL_warnhook); 921 SvREFCNT_dec (PL_warnhook);
919 922
920 SvREFCNT_dec (coro->saved_deffh); 923 SvREFCNT_dec (coro->saved_deffh);
921 SvREFCNT_dec (coro_throw); 924 SvREFCNT_dec (CORO_THROW);
922 925
923 coro_destruct_stacks (aTHX); 926 coro_destruct_stacks (aTHX);
924} 927}
925 928
926INLINE void 929INLINE void
1070static int 1073static int
1071slf_check_set_stacklevel (pTHX_ struct CoroSLF *frame) 1074slf_check_set_stacklevel (pTHX_ struct CoroSLF *frame)
1072{ 1075{
1073 *frame = cctx_ssl_frame; 1076 *frame = cctx_ssl_frame;
1074 1077
1075 return 1; /* execute the restored frame - there must be one */ 1078 return frame->check (aTHX_ frame); /* execute the restored frame - there must be one */
1076} 1079}
1077 1080
1078/* initialises PL_top_env and injects a pseudo-slf-call to sett he stacklevel */ 1081/* initialises PL_top_env and injects a pseudo-slf-call to set the stacklevel */
1079static void NOINLINE 1082static void NOINLINE
1080cctx_prepare (pTHX_ coro_cctx *cctx) 1083cctx_prepare (pTHX_ coro_cctx *cctx)
1081{ 1084{
1082 PL_top_env = &PL_start_env; 1085 PL_top_env = &PL_start_env;
1083 1086
1084 if (cctx->flags & CC_TRACE) 1087 if (cctx->flags & CC_TRACE)
1085 PL_runops = runops_trace; 1088 PL_runops = runops_trace;
1086 1089
1087 /* we already must be in an SLF call, there is no other valid way 1090 /* we already must be executing an SLF op, there is no other valid way
1088 * that can lead to creation of a new cctx */ 1091 * that can lead to creation of a new cctx */
1089 assert (("FATAL: can't prepare slf-less cctx in Coro module (please report)", 1092 assert (("FATAL: can't prepare slf-less cctx in Coro module (please report)",
1090 slf_frame.prepare && PL_op->op_ppaddr == pp_slf)); 1093 slf_frame.prepare && PL_op->op_ppaddr == pp_slf));
1091 1094
1095 /* we must emulate leaving pp_slf, which is done inside slf_check_set_stacklevel */
1092 cctx_ssl_cctx = cctx; 1096 cctx_ssl_cctx = cctx;
1093 cctx_ssl_frame = slf_frame; 1097 cctx_ssl_frame = slf_frame;
1094 1098
1095 slf_frame.prepare = slf_prepare_set_stacklevel; 1099 slf_frame.prepare = slf_prepare_set_stacklevel;
1096 slf_frame.check = slf_check_set_stacklevel; 1100 slf_frame.check = slf_check_set_stacklevel;
1317 dSTACKLEVEL; 1321 dSTACKLEVEL;
1318 1322
1319 /* sometimes transfer is only called to set idle_sp */ 1323 /* sometimes transfer is only called to set idle_sp */
1320 if (expect_false (!next)) 1324 if (expect_false (!next))
1321 { 1325 {
1322 ((coro_cctx *)prev)->idle_sp = (void *)stacklevel; 1326 ((coro_cctx *)prev)->idle_sp = STACKLEVEL;
1323 assert (((coro_cctx *)prev)->idle_te = PL_top_env); /* just for the side-effect when asserts are enabled */ 1327 assert (((coro_cctx *)prev)->idle_te = PL_top_env); /* just for the side-effect when asserts are enabled */
1324 } 1328 }
1325 else if (expect_true (prev != next)) 1329 else if (expect_true (prev != next))
1326 { 1330 {
1327 coro_cctx *prev__cctx; 1331 coro_cctx *prev__cctx;
1352 1356
1353 prev__cctx = prev->cctx; 1357 prev__cctx = prev->cctx;
1354 1358
1355 /* possibly untie and reuse the cctx */ 1359 /* possibly untie and reuse the cctx */
1356 if (expect_true ( 1360 if (expect_true (
1357 prev__cctx->idle_sp == (void *)stacklevel 1361 prev__cctx->idle_sp == STACKLEVEL
1358 && !(prev__cctx->flags & CC_TRACE) 1362 && !(prev__cctx->flags & CC_TRACE)
1359 && !force_cctx 1363 && !force_cctx
1360 )) 1364 ))
1361 { 1365 {
1362 /* I assume that stacklevel is a stronger indicator than PL_top_env changes */ 1366 /* I assume that stacklevel is a stronger indicator than PL_top_env changes */
1835 } 1839 }
1836 while (slf_frame.check (aTHX_ &slf_frame)); 1840 while (slf_frame.check (aTHX_ &slf_frame));
1837 1841
1838 slf_frame.prepare = 0; /* invalidate the frame, we are done processing it */ 1842 slf_frame.prepare = 0; /* invalidate the frame, we are done processing it */
1839 1843
1844 /* exception handling */
1845 if (expect_false (CORO_THROW))
1846 {
1847 SV *exception = sv_2mortal (CORO_THROW);
1848
1849 CORO_THROW = 0;
1850 sv_setsv (ERRSV, exception);
1851 croak (0);
1852 }
1853
1840 /* return value handling - mostly like entersub */ 1854 /* return value handling - mostly like entersub */
1841 /* make sure we put something on the stack in scalar context */ 1855 /* make sure we put something on the stack in scalar context */
1842 if (GIMME_V == G_SCALAR) 1856 if (GIMME_V == G_SCALAR)
1843 { 1857 {
1844 dSP; 1858 dSP;
1850 bot [1] = *sp; 1864 bot [1] = *sp;
1851 1865
1852 SP = bot + 1; 1866 SP = bot + 1;
1853 1867
1854 PUTBACK; 1868 PUTBACK;
1855 }
1856
1857 /* exception handling */
1858 if (expect_false (coro_throw))
1859 {
1860 SV *exception = sv_2mortal (coro_throw);
1861
1862 coro_throw = 0;
1863 sv_setsv (ERRSV, exception);
1864 croak (0);
1865 } 1869 }
1866 1870
1867 return NORMAL; 1871 return NORMAL;
1868} 1872}
1869 1873
1993}; 1997};
1994 1998
1995/*****************************************************************************/ 1999/*****************************************************************************/
1996/* Coro::Semaphore */ 2000/* Coro::Semaphore */
1997 2001
2002static SV *
2003coro_semaphore_new (int count)
2004{
2005 /* a semaphore contains a counter IV in $sem->[0] and any waiters after that */
2006 AV *av = newAV ();
2007 SV **ary;
2008
2009 /* unfortunately, building manually saves memory */
2010 Newx (ary, 2, SV *);
2011 AvALLOC (av) = ary;
2012 AvARRAY (av) = ary;
2013 AvMAX (av) = 1;
2014 AvFILLp (av) = 0;
2015 ary [0] = newSViv (count);
2016
2017 return newRV_noinc ((SV *)av);
2018}
2019
1998static void 2020static void
1999coro_semaphore_adjust (pTHX_ AV *av, IV adjust) 2021coro_semaphore_adjust (pTHX_ AV *av, IV adjust)
2000{ 2022{
2001 SV *count_sv = AvARRAY (av)[0]; 2023 SV *count_sv = AvARRAY (av)[0];
2002 IV count = SvIVX (count_sv); 2024 IV count = SvIVX (count_sv);
2031 /* call $sem->adjust (0) to possibly wake up some other waiters */ 2053 /* call $sem->adjust (0) to possibly wake up some other waiters */
2032 coro_semaphore_adjust (aTHX_ (AV *)coro->slf_frame.data, 0); 2054 coro_semaphore_adjust (aTHX_ (AV *)coro->slf_frame.data, 0);
2033} 2055}
2034 2056
2035static int 2057static int
2036slf_check_semaphore_down (pTHX_ struct CoroSLF *frame) 2058slf_check_semaphore_down_or_wait (pTHX_ struct CoroSLF *frame, int acquire)
2037{ 2059{
2038 AV *av = (AV *)frame->data; 2060 AV *av = (AV *)frame->data;
2039 SV *count_sv = AvARRAY (av)[0]; 2061 SV *count_sv = AvARRAY (av)[0];
2040 2062
2063 /* if we are about to throw, don't actually acquire the lock, just throw */
2064 if (CORO_THROW)
2065 return 0;
2041 if (SvIVX (count_sv) > 0) 2066 else if (SvIVX (count_sv) > 0)
2042 { 2067 {
2043 SvSTATE_current->on_destroy = 0; 2068 SvSTATE_current->on_destroy = 0;
2069
2070 if (acquire)
2044 SvIVX (count_sv) = SvIVX (count_sv) - 1; 2071 SvIVX (count_sv) = SvIVX (count_sv) - 1;
2072 else
2073 coro_semaphore_adjust (aTHX_ av, 0);
2074
2045 return 0; 2075 return 0;
2046 } 2076 }
2047 else 2077 else
2048 { 2078 {
2049 int i; 2079 int i;
2058 av_push (av, SvREFCNT_inc (SvRV (coro_current))); 2088 av_push (av, SvREFCNT_inc (SvRV (coro_current)));
2059 return 1; 2089 return 1;
2060 } 2090 }
2061} 2091}
2062 2092
2063static void 2093static int
2094slf_check_semaphore_down (pTHX_ struct CoroSLF *frame)
2095{
2096 return slf_check_semaphore_down_or_wait (aTHX_ frame, 1);
2097}
2098
2099static int
2100slf_check_semaphore_wait (pTHX_ struct CoroSLF *frame)
2101{
2102 return slf_check_semaphore_down_or_wait (aTHX_ frame, 0);
2103}
2104
2105static void
2064slf_init_semaphore_down (pTHX_ struct CoroSLF *frame, CV *cv, SV **arg, int items) 2106slf_init_semaphore_down_or_wait (pTHX_ struct CoroSLF *frame, CV *cv, SV **arg, int items)
2065{ 2107{
2066 AV *av = (AV *)SvRV (arg [0]); 2108 AV *av = (AV *)SvRV (arg [0]);
2067 2109
2068 if (SvIVX (AvARRAY (av)[0]) > 0) 2110 if (SvIVX (AvARRAY (av)[0]) > 0)
2069 { 2111 {
2070 frame->data = (void *)av; 2112 frame->data = (void *)av;
2071 frame->prepare = prepare_nop; 2113 frame->prepare = prepare_nop;
2072 SvSTATE_current->on_destroy = coro_semaphore_on_destroy;
2073 } 2114 }
2074 else 2115 else
2075 { 2116 {
2076 av_push (av, SvREFCNT_inc (SvRV (coro_current))); 2117 av_push (av, SvREFCNT_inc (SvRV (coro_current)));
2077 2118
2078 frame->data = (void *)sv_2mortal (SvREFCNT_inc ((SV *)av)); 2119 frame->data = (void *)sv_2mortal (SvREFCNT_inc ((SV *)av));
2079 frame->prepare = prepare_schedule; 2120 frame->prepare = prepare_schedule;
2080 2121
2081 /* to avoid race conditions when a woken-up coro gets terminated */ 2122 /* to avoid race conditions when a woken-up coro gets terminated */
2082 /* we arrange for a temporary on_destroy that calls adjust (0) */ 2123 /* we arrange for a temporary on_destroy that calls adjust (0) */
2083 assert (!SvSTATE_current->on_destroy);//D
2084 SvSTATE_current->on_destroy = coro_semaphore_on_destroy; 2124 SvSTATE_current->on_destroy = coro_semaphore_on_destroy;
2085 } 2125 }
2126}
2086 2127
2128static void
2129slf_init_semaphore_down (pTHX_ struct CoroSLF *frame, CV *cv, SV **arg, int items)
2130{
2131 slf_init_semaphore_down_or_wait (aTHX_ frame, cv, arg, items);
2087 frame->check = slf_check_semaphore_down; 2132 frame->check = slf_check_semaphore_down;
2133}
2088 2134
2135static void
2136slf_init_semaphore_wait (pTHX_ struct CoroSLF *frame, CV *cv, SV **arg, int items)
2137{
2138 slf_init_semaphore_down_or_wait (aTHX_ frame, cv, arg, items);
2139 frame->check = slf_check_semaphore_wait;
2089} 2140}
2090 2141
2091/*****************************************************************************/ 2142/*****************************************************************************/
2092/* gensub: simple closure generation utility */ 2143/* gensub: simple closure generation utility */
2093 2144
2165 2216
2166static int 2217static int
2167slf_check_aio_req (pTHX_ struct CoroSLF *frame) 2218slf_check_aio_req (pTHX_ struct CoroSLF *frame)
2168{ 2219{
2169 AV *state = (AV *)frame->data; 2220 AV *state = (AV *)frame->data;
2221
2222 /* if we are about to throw, return early */
2223 /* this does not cancel the aio request, but at least */
2224 /* it quickly returns */
2225 if (CORO_THROW)
2226 return 0;
2170 2227
2171 /* one element that is an RV? repeat! */ 2228 /* one element that is an RV? repeat! */
2172 if (AvFILLp (state) == 0 && SvROK (AvARRAY (state)[0])) 2229 if (AvFILLp (state) == 0 && SvROK (AvARRAY (state)[0]))
2173 return 1; 2230 return 1;
2174 2231
2506throw (Coro::State self, SV *throw = &PL_sv_undef) 2563throw (Coro::State self, SV *throw = &PL_sv_undef)
2507 PROTOTYPE: $;$ 2564 PROTOTYPE: $;$
2508 CODE: 2565 CODE:
2509{ 2566{
2510 struct coro *current = SvSTATE_current; 2567 struct coro *current = SvSTATE_current;
2511 SV **throwp = self == current ? &coro_throw : &self->throw; 2568 SV **throwp = self == current ? &CORO_THROW : &self->except;
2512 SvREFCNT_dec (*throwp); 2569 SvREFCNT_dec (*throwp);
2513 *throwp = SvOK (throw) ? newSVsv (throw) : 0; 2570 *throwp = SvOK (throw) ? newSVsv (throw) : 0;
2514} 2571}
2515 2572
2516void 2573void
2605 coroapi.ready = api_ready; 2662 coroapi.ready = api_ready;
2606 coroapi.is_ready = api_is_ready; 2663 coroapi.is_ready = api_is_ready;
2607 coroapi.nready = coro_nready; 2664 coroapi.nready = coro_nready;
2608 coroapi.current = coro_current; 2665 coroapi.current = coro_current;
2609 2666
2610 GCoroAPI = &coroapi; 2667 /*GCoroAPI = &coroapi;*/
2611 sv_setiv (sv, (IV)&coroapi); 2668 sv_setiv (sv, (IV)&coroapi);
2612 SvREADONLY_on (sv); 2669 SvREADONLY_on (sv);
2613 } 2670 }
2614} 2671}
2615 2672
2761 2818
2762 2819
2763MODULE = Coro::State PACKAGE = Coro::Semaphore 2820MODULE = Coro::State PACKAGE = Coro::Semaphore
2764 2821
2765SV * 2822SV *
2766new (SV *klass, SV *count_ = 0) 2823new (SV *klass, SV *count = 0)
2767 CODE: 2824 CODE:
2768{ 2825 RETVAL = sv_bless (
2769 /* a semaphore contains a counter IV in $sem->[0] and any waiters after that */ 2826 coro_semaphore_new (count && SvOK (count) ? SvIV (count) : 1),
2770 AV *av = newAV (); 2827 GvSTASH (CvGV (cv))
2771 SV **ary; 2828 );
2829 OUTPUT:
2830 RETVAL
2772 2831
2773 /* unfortunately, building manually saves memory */ 2832# helper for Coro::Channel
2774 Newx (ary, 2, SV *); 2833SV *
2775 AvALLOC (av) = ary; 2834_alloc (int count)
2776 AvARRAY (av) = ary; 2835 CODE:
2777 AvMAX (av) = 1; 2836 RETVAL = coro_semaphore_new (count);
2778 AvFILLp (av) = 0;
2779 ary [0] = newSViv (count_ && SvOK (count_) ? SvIV (count_) : 1);
2780
2781 RETVAL = sv_bless (newRV_noinc ((SV *)av), GvSTASH (CvGV (cv)));
2782}
2783 OUTPUT: 2837 OUTPUT:
2784 RETVAL 2838 RETVAL
2785 2839
2786SV * 2840SV *
2787count (SV *self) 2841count (SV *self)
2797 CODE: 2851 CODE:
2798 coro_semaphore_adjust (aTHX_ (AV *)SvRV (self), ix ? adjust : 1); 2852 coro_semaphore_adjust (aTHX_ (AV *)SvRV (self), ix ? adjust : 1);
2799 2853
2800void 2854void
2801down (SV *self) 2855down (SV *self)
2856 ALIAS:
2857 Coro::Signal::wait = 0
2802 CODE: 2858 CODE:
2803 CORO_EXECUTE_SLF_XS (slf_init_semaphore_down); 2859 CORO_EXECUTE_SLF_XS (slf_init_semaphore_down);
2860
2861void
2862wait (SV *self)
2863 CODE:
2864 CORO_EXECUTE_SLF_XS (slf_init_semaphore_wait);
2804 2865
2805void 2866void
2806try (SV *self) 2867try (SV *self)
2807 PPCODE: 2868 PPCODE:
2808{ 2869{
2820 XSRETURN_NO; 2881 XSRETURN_NO;
2821} 2882}
2822 2883
2823void 2884void
2824waiters (SV *self) 2885waiters (SV *self)
2825 CODE: 2886 PPCODE:
2826{ 2887{
2827 AV *av = (AV *)SvRV (self); 2888 AV *av = (AV *)SvRV (self);
2889 int wcount = AvFILLp (av) + 1 - 1;
2828 2890
2829 if (GIMME_V == G_SCALAR) 2891 if (GIMME_V == G_SCALAR)
2830 XPUSHs (sv_2mortal (newSVsv (AvARRAY (av)[0]))); 2892 XPUSHs (sv_2mortal (newSViv (wcount)));
2831 else 2893 else
2832 { 2894 {
2833 int i; 2895 int i;
2834 EXTEND (SP, AvFILLp (av) + 1 - 1); 2896 EXTEND (SP, wcount);
2835 for (i = 1; i <= AvFILLp (av); ++i) 2897 for (i = 1; i <= wcount; ++i)
2836 PUSHs (sv_2mortal (newRV_inc (AvARRAY (av)[i]))); 2898 PUSHs (sv_2mortal (newRV_inc (AvARRAY (av)[i])));
2837 } 2899 }
2900}
2901
2902MODULE = Coro::State PACKAGE = Coro::Signal
2903
2904SV *
2905new (SV *klass)
2906 CODE:
2907 RETVAL = sv_bless (
2908 coro_semaphore_new (0),
2909 GvSTASH (CvGV (cv))
2910 );
2911 OUTPUT:
2912 RETVAL
2913
2914void
2915broadcast (SV *self, int adjust = 1)
2916 CODE:
2917{
2918 AV *av = (AV *)SvRV (self);
2919 SvIVX (AvARRAY (av)[0]) = 0; /* not necessary, but gives me fuzzy warm feelings */
2920 coro_semaphore_adjust (aTHX_ av, AvFILLp (av) + 1 - 1);
2921 SvIVX (AvARRAY (av)[0]) = 0; /* necessary */
2838} 2922}
2839 2923
2840 2924
2841MODULE = Coro::State PACKAGE = Coro::AnyEvent 2925MODULE = Coro::State PACKAGE = Coro::AnyEvent
2842 2926

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines