… | |
… | |
327 | return get_hv (name, create); |
327 | return get_hv (name, create); |
328 | } |
328 | } |
329 | |
329 | |
330 | /* may croak */ |
330 | /* may croak */ |
331 | INLINE CV * |
331 | INLINE CV * |
332 | coro_sv_2cv (SV *sv) |
332 | coro_sv_2cv (pTHX_ SV *sv) |
333 | { |
333 | { |
334 | HV *st; |
334 | HV *st; |
335 | GV *gvp; |
335 | GV *gvp; |
336 | return sv_2cv (sv, &st, &gvp, 0); |
336 | return sv_2cv (sv, &st, &gvp, 0); |
337 | } |
337 | } |
… | |
… | |
2299 | { |
2299 | { |
2300 | if (items >= 2) |
2300 | if (items >= 2) |
2301 | { |
2301 | { |
2302 | /* callback form */ |
2302 | /* callback form */ |
2303 | AV *av = (AV *)SvRV (arg [0]); |
2303 | AV *av = (AV *)SvRV (arg [0]); |
2304 | CV *cb_cv = coro_sv_2cv (arg [1]); |
2304 | CV *cb_cv = coro_sv_2cv (aTHX_ arg [1]); |
2305 | |
2305 | |
2306 | av_push (av, (SV *)SvREFCNT_inc_NN (cb_cv)); |
2306 | av_push (av, (SV *)SvREFCNT_inc_NN (cb_cv)); |
2307 | |
2307 | |
2308 | if (SvIVX (AvARRAY (av)[0]) > 0) |
2308 | if (SvIVX (AvARRAY (av)[0]) > 0) |
2309 | coro_semaphore_adjust (aTHX_ av, 0); |
2309 | coro_semaphore_adjust (aTHX_ av, 0); |
… | |
… | |
2627 | CV *cb; |
2627 | CV *cb; |
2628 | int i; |
2628 | int i; |
2629 | |
2629 | |
2630 | if (items > 1) |
2630 | if (items > 1) |
2631 | { |
2631 | { |
2632 | cb = coro_sv_2cv (ST (1)); |
2632 | cb = coro_sv_2cv (aTHX_ ST (1)); |
2633 | |
2633 | |
2634 | if (!ix) |
2634 | if (!ix) |
2635 | { |
2635 | { |
2636 | if (CvISXSUB (cb)) |
2636 | if (CvISXSUB (cb)) |
2637 | croak ("Coro::State doesn't support XS functions as coroutine start, caught"); |
2637 | croak ("Coro::State doesn't support XS functions as coroutine start, caught"); |
… | |
… | |
2877 | int i; |
2877 | int i; |
2878 | |
2878 | |
2879 | av_async_pool = coro_get_av (aTHX_ "Coro::async_pool", TRUE); |
2879 | av_async_pool = coro_get_av (aTHX_ "Coro::async_pool", TRUE); |
2880 | sv_pool_rss = coro_get_sv (aTHX_ "Coro::POOL_RSS" , TRUE); |
2880 | sv_pool_rss = coro_get_sv (aTHX_ "Coro::POOL_RSS" , TRUE); |
2881 | sv_pool_size = coro_get_sv (aTHX_ "Coro::POOL_SIZE" , TRUE); |
2881 | sv_pool_size = coro_get_sv (aTHX_ "Coro::POOL_SIZE" , TRUE); |
2882 | cv_coro_run = get_cv (aTHX_ "Coro::_terminate", GV_ADD); |
2882 | cv_coro_run = get_cv ( "Coro::_terminate", GV_ADD); |
2883 | coro_current = coro_get_sv (aTHX_ "Coro::current" , FALSE); |
2883 | coro_current = coro_get_sv (aTHX_ "Coro::current" , FALSE); |
2884 | SvREADONLY_on (coro_current); |
2884 | SvREADONLY_on (coro_current); |
2885 | |
2885 | |
2886 | coro_stash = gv_stashpv ("Coro", TRUE); |
2886 | coro_stash = gv_stashpv ("Coro", TRUE); |
2887 | |
2887 | |
… | |
… | |
3231 | |
3231 | |
3232 | void |
3232 | void |
3233 | _register (char *target, char *proto, SV *req) |
3233 | _register (char *target, char *proto, SV *req) |
3234 | CODE: |
3234 | CODE: |
3235 | { |
3235 | { |
3236 | CV *req_cv = coro_sv_2cv (req); |
3236 | CV *req_cv = coro_sv_2cv (aTHX_ req); |
3237 | /* newXSproto doesn't return the CV on 5.8 */ |
3237 | /* newXSproto doesn't return the CV on 5.8 */ |
3238 | CV *slf_cv = newXS (target, coro_aio_req_xs, __FILE__); |
3238 | CV *slf_cv = newXS (target, coro_aio_req_xs, __FILE__); |
3239 | sv_setpv ((SV *)slf_cv, proto); |
3239 | sv_setpv ((SV *)slf_cv, proto); |
3240 | sv_magicext ((SV *)slf_cv, (SV *)req_cv, CORO_MAGIC_type_aio, 0, 0, 0); |
3240 | sv_magicext ((SV *)slf_cv, (SV *)req_cv, CORO_MAGIC_type_aio, 0, 0, 0); |
3241 | } |
3241 | } |