… | |
… | |
165 | static size_t cctx_stacksize = CORO_STACKSIZE; |
165 | static size_t cctx_stacksize = CORO_STACKSIZE; |
166 | static struct CoroAPI coroapi; |
166 | static struct CoroAPI coroapi; |
167 | static AV *main_mainstack; /* used to differentiate between $main and others */ |
167 | static AV *main_mainstack; /* used to differentiate between $main and others */ |
168 | static JMPENV *main_top_env; |
168 | static JMPENV *main_top_env; |
169 | static HV *coro_state_stash, *coro_stash; |
169 | static HV *coro_state_stash, *coro_stash; |
170 | static CV *coro_run_cv; |
|
|
171 | static volatile SV *coro_mortal; /* will be freed/thrown after next transfer */ |
170 | static volatile SV *coro_mortal; /* will be freed/thrown after next transfer */ |
172 | |
171 | |
173 | static GV *irsgv; /* $/ */ |
172 | static GV *irsgv; /* $/ */ |
174 | static GV *stdoutgv; /* *STDOUT */ |
173 | static GV *stdoutgv; /* *STDOUT */ |
175 | static SV *rv_diehook; |
174 | static SV *rv_diehook; |
… | |
… | |
290 | |
289 | |
291 | /* for Coro.pm */ |
290 | /* for Coro.pm */ |
292 | static SV *coro_current; |
291 | static SV *coro_current; |
293 | static SV *coro_readyhook; |
292 | static SV *coro_readyhook; |
294 | static AV *coro_ready [PRIO_MAX - PRIO_MIN + 1]; |
293 | static AV *coro_ready [PRIO_MAX - PRIO_MIN + 1]; |
|
|
294 | static CV *cv_coro_run; |
295 | static struct coro *coro_first; |
295 | static struct coro *coro_first; |
296 | #define coro_nready coroapi.nready |
296 | #define coro_nready coroapi.nready |
297 | |
297 | |
298 | /** lowlevel stuff **********************************************************/ |
298 | /** lowlevel stuff **********************************************************/ |
299 | |
299 | |
… | |
… | |
2629 | |
2629 | |
2630 | if (items > 1) |
2630 | if (items > 1) |
2631 | { |
2631 | { |
2632 | cb = coro_sv_2cv (ST (1)); |
2632 | cb = coro_sv_2cv (ST (1)); |
2633 | |
2633 | |
|
|
2634 | if (!ix) |
|
|
2635 | { |
2634 | if (CvISXSUB (cb)) |
2636 | if (CvISXSUB (cb)) |
2635 | 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"); |
2636 | |
2638 | |
2637 | if (!CvROOT (cb)) |
2639 | if (!CvROOT (cb)) |
2638 | croak ("Coro::State doesn't support autoloaded or undefined functions as coroutine start, caught"); |
2640 | croak ("Coro::State doesn't support autoloaded or undefined functions as coroutine start, caught"); |
|
|
2641 | } |
2639 | } |
2642 | } |
2640 | |
2643 | |
2641 | Newz (0, coro, 1, struct coro); |
2644 | Newz (0, coro, 1, struct coro); |
2642 | coro->args = newAV (); |
2645 | coro->args = newAV (); |
2643 | coro->flags = CF_NEW; |
2646 | coro->flags = CF_NEW; |
… | |
… | |
2656 | av_extend (coro->args, items - 1 + ix); |
2659 | av_extend (coro->args, items - 1 + ix); |
2657 | |
2660 | |
2658 | if (ix) |
2661 | if (ix) |
2659 | { |
2662 | { |
2660 | av_push (coro->args, SvREFCNT_inc_NN ((SV *)cb)); |
2663 | av_push (coro->args, SvREFCNT_inc_NN ((SV *)cb)); |
2661 | cb = coro_run_cv; |
2664 | cb = cv_coro_run; |
2662 | } |
2665 | } |
2663 | |
2666 | |
2664 | coro->startcv = (CV *)SvREFCNT_inc_NN ((SV *)cb); |
2667 | coro->startcv = (CV *)SvREFCNT_inc_NN ((SV *)cb); |
2665 | |
2668 | |
2666 | for (i = 2; i < items; i++) |
2669 | for (i = 2; i < items; i++) |
… | |
… | |
2874 | int i; |
2877 | int i; |
2875 | |
2878 | |
2876 | av_async_pool = coro_get_av (aTHX_ "Coro::async_pool", TRUE); |
2879 | av_async_pool = coro_get_av (aTHX_ "Coro::async_pool", TRUE); |
2877 | sv_pool_rss = coro_get_sv (aTHX_ "Coro::POOL_RSS" , TRUE); |
2880 | sv_pool_rss = coro_get_sv (aTHX_ "Coro::POOL_RSS" , TRUE); |
2878 | sv_pool_size = coro_get_sv (aTHX_ "Coro::POOL_SIZE" , TRUE); |
2881 | sv_pool_size = coro_get_sv (aTHX_ "Coro::POOL_SIZE" , TRUE); |
2879 | coro_run_cv = get_cv (aTHX_ "Coro::_terminate", GV_ADD); |
2882 | cv_coro_run = get_cv (aTHX_ "Coro::_terminate", GV_ADD); |
2880 | coro_current = coro_get_sv (aTHX_ "Coro::current" , FALSE); |
2883 | coro_current = coro_get_sv (aTHX_ "Coro::current" , FALSE); |
2881 | SvREADONLY_on (coro_current); |
2884 | SvREADONLY_on (coro_current); |
2882 | |
2885 | |
2883 | coro_stash = gv_stashpv ("Coro", TRUE); |
2886 | coro_stash = gv_stashpv ("Coro", TRUE); |
2884 | |
2887 | |