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.363 by root, Tue Jul 14 00:55:10 2009 UTC vs.
Revision 1.364 by root, Thu Jul 16 02:19:17 2009 UTC

282static SV *coro_readyhook; 282static SV *coro_readyhook;
283static struct coro *coro_ready [CORO_PRIO_MAX - CORO_PRIO_MIN + 1][2]; /* head|tail */ 283static struct coro *coro_ready [CORO_PRIO_MAX - CORO_PRIO_MIN + 1][2]; /* head|tail */
284static CV *cv_coro_run, *cv_coro_terminate; 284static CV *cv_coro_run, *cv_coro_terminate;
285static struct coro *coro_first; 285static struct coro *coro_first;
286#define coro_nready coroapi.nready 286#define coro_nready coroapi.nready
287
288/** Coro::Select ************************************************************/
289
290static OP *(*coro_old_pp_sselect) (pTHX);
291static SV *coro_select_select;
292
293/* horrible hack, but if it works... */
294static OP *
295coro_pp_sselect (aTHX)
296{
297 dSP;
298 PUSHMARK (SP - 4); /* fake argument list */
299 XPUSHs (coro_select_select);
300 PUTBACK;
301
302 /* entersub is an UNOP, select a LISTOP... keep your fingers crossed */
303 PL_op->op_flags |= OPf_STACKED;
304 PL_op->op_private = 0;
305 return PL_ppaddr [OP_ENTERSUB](aTHX);
306}
287 307
288/** lowlevel stuff **********************************************************/ 308/** lowlevel stuff **********************************************************/
289 309
290static SV * 310static SV *
291coro_get_sv (pTHX_ const char *name, int create) 311coro_get_sv (pTHX_ const char *name, int create)
3717 CV *slf_cv = newXS (target, coro_aio_req_xs, __FILE__); 3737 CV *slf_cv = newXS (target, coro_aio_req_xs, __FILE__);
3718 sv_setpv ((SV *)slf_cv, proto); 3738 sv_setpv ((SV *)slf_cv, proto);
3719 sv_magicext ((SV *)slf_cv, (SV *)req_cv, CORO_MAGIC_type_aio, 0, 0, 0); 3739 sv_magicext ((SV *)slf_cv, (SV *)req_cv, CORO_MAGIC_type_aio, 0, 0, 0);
3720} 3740}
3721 3741
3742MODULE = Coro::State PACKAGE = Coro::Select
3743
3744void
3745patch_pp_sselect ()
3746 CODE:
3747 if (!coro_old_pp_sselect)
3748 {
3749 coro_select_select = (SV *)get_cv ("Coro::Select::select", 0);
3750 coro_old_pp_sselect = PL_ppaddr [OP_SSELECT];
3751 PL_ppaddr [OP_SSELECT] = coro_pp_sselect;
3752 }
3753
3754void
3755unpatch_pp_sselect ()
3756 CODE:
3757 if (coro_old_pp_sselect)
3758 {
3759 PL_ppaddr [OP_SSELECT] = coro_old_pp_sselect;
3760 coro_old_pp_sselect = 0;
3761 }
3762
3763

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines