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.250 by root, Wed Oct 22 16:34:07 2008 UTC vs.
Revision 1.252 by root, Tue Nov 4 12:08:44 2008 UTC

81# ifndef IS_PADCONST 81# ifndef IS_PADCONST
82# define IS_PADCONST(v) 0 82# define IS_PADCONST(v) 0
83# endif 83# endif
84#endif 84#endif
85 85
86/* 5.11 */
87#ifndef CxHASARGS
88# define CxHASARGS(cx) (cx)->blk_sub.hasargs
89#endif
90
91/* 5.10.0 */
92#ifndef SvREFCNT_inc_NN
93# define SvREFCNT_inc_NN(sv) SvREFCNT_inc (sv)
94#endif
95
86/* 5.8.8 */ 96/* 5.8.8 */
87#ifndef GV_NOTQUAL 97#ifndef GV_NOTQUAL
88# define GV_NOTQUAL 0 98# define GV_NOTQUAL 0
89#endif 99#endif
90#ifndef newSV 100#ifndef newSV
91# define newSV(l) NEWSV(0,l) 101# define newSV(l) NEWSV(0,l)
92#endif
93#ifndef SvREFCNT_inc_NN
94# define SvREFCNT_inc_NN(sv) SvREFCNT_inc (sv)
95#endif
96
97/* 5.11 */
98#ifndef CxHASARGS
99# define CxHASARGS(cx) (cx)->blk_sub.hasargs
100#endif 102#endif
101 103
102/* 5.8.7 */ 104/* 5.8.7 */
103#ifndef SvRV_set 105#ifndef SvRV_set
104# define SvRV_set(s,v) SvRV(s) = (v) 106# define SvRV_set(s,v) SvRV(s) = (v)
165static size_t coro_stacksize = CORO_STACKSIZE; 167static size_t coro_stacksize = CORO_STACKSIZE;
166static struct CoroAPI coroapi; 168static struct CoroAPI coroapi;
167static AV *main_mainstack; /* used to differentiate between $main and others */ 169static AV *main_mainstack; /* used to differentiate between $main and others */
168static JMPENV *main_top_env; 170static JMPENV *main_top_env;
169static HV *coro_state_stash, *coro_stash; 171static HV *coro_state_stash, *coro_stash;
170static volatile SV *coro_mortal; /* will be freed after next transfer */ 172static volatile SV *coro_mortal; /* will be freed/thrown after next transfer */
171 173
172static GV *irsgv; /* $/ */ 174static GV *irsgv; /* $/ */
173static GV *stdoutgv; /* *STDOUT */ 175static GV *stdoutgv; /* *STDOUT */
174static SV *rv_diehook; 176static SV *rv_diehook;
175static SV *rv_warnhook; 177static SV *rv_warnhook;
1206/* always use the TRANSFER macro */ 1208/* always use the TRANSFER macro */
1207static void NOINLINE 1209static void NOINLINE
1208transfer (pTHX_ struct coro *prev, struct coro *next, int force_cctx) 1210transfer (pTHX_ struct coro *prev, struct coro *next, int force_cctx)
1209{ 1211{
1210 dSTACKLEVEL; 1212 dSTACKLEVEL;
1211 static volatile int has_throw;
1212 1213
1213 /* sometimes transfer is only called to set idle_sp */ 1214 /* sometimes transfer is only called to set idle_sp */
1214 if (expect_false (!next)) 1215 if (expect_false (!next))
1215 { 1216 {
1216 ((coro_cctx *)prev)->idle_sp = STACKLEVEL; 1217 ((coro_cctx *)prev)->idle_sp = STACKLEVEL;
1217 assert (((coro_cctx *)prev)->idle_te = PL_top_env); /* just for the side-effect when asserts are enabled */ 1218 assert (((coro_cctx *)prev)->idle_te = PL_top_env); /* just for the side-effect when asserts are enabled */
1218 } 1219 }
1219 else if (expect_true (prev != next)) 1220 else if (expect_true (prev != next))
1220 { 1221 {
1222 static volatile int has_throw;
1221 coro_cctx *prev__cctx; 1223 coro_cctx *prev__cctx;
1222 1224
1223 if (expect_false (prev->flags & CF_NEW)) 1225 if (expect_false (prev->flags & CF_NEW))
1224 { 1226 {
1225 /* create a new empty context */ 1227 /* create a new empty context */
1832 ta.next = 0; 1834 ta.next = 0;
1833 break; 1835 break;
1834 1836
1835 case 1: 1837 case 1:
1836 if (items != 2) 1838 if (items != 2)
1837 croak ("Coro::State::transfer (prev,next) expects two arguments, not %d", items); 1839 croak ("Coro::State::transfer (prev, next) expects two arguments, not %d", items);
1838 1840
1839 prepare_transfer (aTHX_ &ta, ST (0), ST (1)); 1841 prepare_transfer (aTHX_ &ta, ST (0), ST (1));
1840 break; 1842 break;
1841 1843
1842 case 2: 1844 case 2:
2005 CODE: 2007 CODE:
2006 struct coro *coro = SvSTATE (coro_current); 2008 struct coro *coro = SvSTATE (coro_current);
2007 coro->cctx->idle_sp = 0; 2009 coro->cctx->idle_sp = 0;
2008 2010
2009void 2011void
2010throw (Coro::State self, SV *throw = &PL_sv_undef)
2011 PROTOTYPE: $;$
2012 CODE:
2013 SvREFCNT_dec (self->throw);
2014 self->throw = SvOK (throw) ? newSVsv (throw) : 0;
2015
2016void
2017swap_defsv (Coro::State self) 2012swap_defsv (Coro::State self)
2018 PROTOTYPE: $ 2013 PROTOTYPE: $
2019 ALIAS: 2014 ALIAS:
2020 swap_defav = 1 2015 swap_defav = 1
2021 CODE: 2016 CODE:
2124 CODE: 2119 CODE:
2125 RETVAL = coro_nready; 2120 RETVAL = coro_nready;
2126 OUTPUT: 2121 OUTPUT:
2127 RETVAL 2122 RETVAL
2128 2123
2124void
2125throw (Coro::State self, SV *throw = &PL_sv_undef)
2126 PROTOTYPE: $;$
2127 CODE:
2128 SvREFCNT_dec (self->throw);
2129 self->throw = SvOK (throw) ? newSVsv (throw) : 0;
2130
2129# for async_pool speedup 2131# for async_pool speedup
2130void 2132void
2131_pool_1 (SV *cb) 2133_pool_1 (SV *cb)
2132 CODE: 2134 CODE:
2133{ 2135{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines