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.251 by root, Thu Oct 30 09:44:31 2008 UTC vs.
Revision 1.252 by root, Tue Nov 4 12:08:44 2008 UTC

167static size_t coro_stacksize = CORO_STACKSIZE; 167static size_t coro_stacksize = CORO_STACKSIZE;
168static struct CoroAPI coroapi; 168static struct CoroAPI coroapi;
169static AV *main_mainstack; /* used to differentiate between $main and others */ 169static AV *main_mainstack; /* used to differentiate between $main and others */
170static JMPENV *main_top_env; 170static JMPENV *main_top_env;
171static HV *coro_state_stash, *coro_stash; 171static HV *coro_state_stash, *coro_stash;
172static volatile SV *coro_mortal; /* will be freed after next transfer */ 172static volatile SV *coro_mortal; /* will be freed/thrown after next transfer */
173 173
174static GV *irsgv; /* $/ */ 174static GV *irsgv; /* $/ */
175static GV *stdoutgv; /* *STDOUT */ 175static GV *stdoutgv; /* *STDOUT */
176static SV *rv_diehook; 176static SV *rv_diehook;
177static SV *rv_warnhook; 177static SV *rv_warnhook;
1208/* always use the TRANSFER macro */ 1208/* always use the TRANSFER macro */
1209static void NOINLINE 1209static void NOINLINE
1210transfer (pTHX_ struct coro *prev, struct coro *next, int force_cctx) 1210transfer (pTHX_ struct coro *prev, struct coro *next, int force_cctx)
1211{ 1211{
1212 dSTACKLEVEL; 1212 dSTACKLEVEL;
1213 static volatile int has_throw;
1214 1213
1215 /* sometimes transfer is only called to set idle_sp */ 1214 /* sometimes transfer is only called to set idle_sp */
1216 if (expect_false (!next)) 1215 if (expect_false (!next))
1217 { 1216 {
1218 ((coro_cctx *)prev)->idle_sp = STACKLEVEL; 1217 ((coro_cctx *)prev)->idle_sp = STACKLEVEL;
1219 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 */
1220 } 1219 }
1221 else if (expect_true (prev != next)) 1220 else if (expect_true (prev != next))
1222 { 1221 {
1222 static volatile int has_throw;
1223 coro_cctx *prev__cctx; 1223 coro_cctx *prev__cctx;
1224 1224
1225 if (expect_false (prev->flags & CF_NEW)) 1225 if (expect_false (prev->flags & CF_NEW))
1226 { 1226 {
1227 /* create a new empty context */ 1227 /* create a new empty context */
1834 ta.next = 0; 1834 ta.next = 0;
1835 break; 1835 break;
1836 1836
1837 case 1: 1837 case 1:
1838 if (items != 2) 1838 if (items != 2)
1839 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);
1840 1840
1841 prepare_transfer (aTHX_ &ta, ST (0), ST (1)); 1841 prepare_transfer (aTHX_ &ta, ST (0), ST (1));
1842 break; 1842 break;
1843 1843
1844 case 2: 1844 case 2:
2007 CODE: 2007 CODE:
2008 struct coro *coro = SvSTATE (coro_current); 2008 struct coro *coro = SvSTATE (coro_current);
2009 coro->cctx->idle_sp = 0; 2009 coro->cctx->idle_sp = 0;
2010 2010
2011void 2011void
2012throw (Coro::State self, SV *throw = &PL_sv_undef)
2013 PROTOTYPE: $;$
2014 CODE:
2015 SvREFCNT_dec (self->throw);
2016 self->throw = SvOK (throw) ? newSVsv (throw) : 0;
2017
2018void
2019swap_defsv (Coro::State self) 2012swap_defsv (Coro::State self)
2020 PROTOTYPE: $ 2013 PROTOTYPE: $
2021 ALIAS: 2014 ALIAS:
2022 swap_defav = 1 2015 swap_defav = 1
2023 CODE: 2016 CODE:
2126 CODE: 2119 CODE:
2127 RETVAL = coro_nready; 2120 RETVAL = coro_nready;
2128 OUTPUT: 2121 OUTPUT:
2129 RETVAL 2122 RETVAL
2130 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
2131# for async_pool speedup 2131# for async_pool speedup
2132void 2132void
2133_pool_1 (SV *cb) 2133_pool_1 (SV *cb)
2134 CODE: 2134 CODE:
2135{ 2135{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines