… | |
… | |
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; |
170 | static volatile SV *coro_mortal; /* will be freed/thrown after next transfer */ |
171 | static volatile SV *coro_mortal; /* will be freed/thrown after next transfer */ |
171 | |
172 | |
172 | static GV *irsgv; /* $/ */ |
173 | static GV *irsgv; /* $/ */ |
173 | static GV *stdoutgv; /* *STDOUT */ |
174 | static GV *stdoutgv; /* *STDOUT */ |
174 | static SV *rv_diehook; |
175 | static SV *rv_diehook; |
… | |
… | |
2614 | assert (("PRIO_NORMAL must be 0", !PRIO_NORMAL)); |
2615 | assert (("PRIO_NORMAL must be 0", !PRIO_NORMAL)); |
2615 | } |
2616 | } |
2616 | |
2617 | |
2617 | SV * |
2618 | SV * |
2618 | new (char *klass, ...) |
2619 | new (char *klass, ...) |
|
|
2620 | ALIAS: |
|
|
2621 | Coro::new = 1 |
2619 | CODE: |
2622 | CODE: |
2620 | { |
2623 | { |
2621 | struct coro *coro; |
2624 | struct coro *coro; |
2622 | MAGIC *mg; |
2625 | MAGIC *mg; |
2623 | HV *hv; |
2626 | HV *hv; |
… | |
… | |
2648 | mg->mg_flags |= MGf_DUP; |
2651 | mg->mg_flags |= MGf_DUP; |
2649 | RETVAL = sv_bless (newRV_noinc ((SV *)hv), gv_stashpv (klass, 1)); |
2652 | RETVAL = sv_bless (newRV_noinc ((SV *)hv), gv_stashpv (klass, 1)); |
2650 | |
2653 | |
2651 | if (items > 1) |
2654 | if (items > 1) |
2652 | { |
2655 | { |
2653 | coro->startcv = SvREFCNT_inc_NN (cb); |
|
|
2654 | |
|
|
2655 | av_extend (coro->args, items - 1); |
2656 | av_extend (coro->args, items - 1 + ix); |
|
|
2657 | |
|
|
2658 | if (ix) |
|
|
2659 | { |
|
|
2660 | av_push (coro->args, SvREFCNT_inc_NN ((SV *)cb)); |
|
|
2661 | cb = coro_run_cv; |
|
|
2662 | } |
|
|
2663 | |
|
|
2664 | coro->startcv = (CV *)SvREFCNT_inc_NN ((SV *)cb); |
|
|
2665 | |
2656 | for (i = 2; i < items; i++) |
2666 | for (i = 2; i < items; i++) |
2657 | av_push (coro->args, newSVsv (ST (i))); |
2667 | av_push (coro->args, newSVsv (ST (i))); |
2658 | } |
2668 | } |
2659 | } |
2669 | } |
2660 | OUTPUT: |
2670 | OUTPUT: |
… | |
… | |
2864 | int i; |
2874 | int i; |
2865 | |
2875 | |
2866 | av_async_pool = coro_get_av (aTHX_ "Coro::async_pool", TRUE); |
2876 | av_async_pool = coro_get_av (aTHX_ "Coro::async_pool", TRUE); |
2867 | sv_pool_rss = coro_get_sv (aTHX_ "Coro::POOL_RSS" , TRUE); |
2877 | sv_pool_rss = coro_get_sv (aTHX_ "Coro::POOL_RSS" , TRUE); |
2868 | sv_pool_size = coro_get_sv (aTHX_ "Coro::POOL_SIZE" , TRUE); |
2878 | sv_pool_size = coro_get_sv (aTHX_ "Coro::POOL_SIZE" , TRUE); |
2869 | |
2879 | coro_run_cv = get_cv (aTHX_ "Coro::_terminate", GV_ADD); |
2870 | coro_current = coro_get_sv (aTHX_ "Coro::current", FALSE); |
2880 | coro_current = coro_get_sv (aTHX_ "Coro::current" , FALSE); |
2871 | SvREADONLY_on (coro_current); |
2881 | SvREADONLY_on (coro_current); |
2872 | |
2882 | |
2873 | coro_stash = gv_stashpv ("Coro", TRUE); |
2883 | coro_stash = gv_stashpv ("Coro", TRUE); |
2874 | |
2884 | |
2875 | newCONSTSUB (coro_stash, "PRIO_MAX", newSViv (PRIO_MAX)); |
2885 | newCONSTSUB (coro_stash, "PRIO_MAX", newSViv (PRIO_MAX)); |