… | |
… | |
282 | static SV *coro_readyhook; |
282 | static SV *coro_readyhook; |
283 | static struct coro *coro_ready [CORO_PRIO_MAX - CORO_PRIO_MIN + 1][2]; /* head|tail */ |
283 | static struct coro *coro_ready [CORO_PRIO_MAX - CORO_PRIO_MIN + 1][2]; /* head|tail */ |
284 | static CV *cv_coro_run, *cv_coro_terminate; |
284 | static CV *cv_coro_run, *cv_coro_terminate; |
285 | static struct coro *coro_first; |
285 | static struct coro *coro_first; |
286 | #define coro_nready coroapi.nready |
286 | #define coro_nready coroapi.nready |
|
|
287 | |
|
|
288 | /** Coro::Select ************************************************************/ |
|
|
289 | |
|
|
290 | static OP *(*coro_old_pp_sselect) (pTHX); |
|
|
291 | static SV *coro_select_select; |
|
|
292 | |
|
|
293 | /* horrible hack, but if it works... */ |
|
|
294 | static OP * |
|
|
295 | coro_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 | |
290 | static SV * |
310 | static SV * |
291 | coro_get_sv (pTHX_ const char *name, int create) |
311 | coro_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 | |
|
|
3742 | MODULE = Coro::State PACKAGE = Coro::Select |
|
|
3743 | |
|
|
3744 | void |
|
|
3745 | patch_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 | |
|
|
3754 | void |
|
|
3755 | unpatch_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 | |