… | |
… | |
1159 | struct coro *current = SvSTATE_current; |
1159 | struct coro *current = SvSTATE_current; |
1160 | |
1160 | |
1161 | assert (("FATAL: tried to destroy currently running coroutine", coro->mainstack != PL_mainstack)); |
1161 | assert (("FATAL: tried to destroy currently running coroutine", coro->mainstack != PL_mainstack)); |
1162 | |
1162 | |
1163 | save_perl (aTHX_ current); |
1163 | save_perl (aTHX_ current); |
|
|
1164 | SvRV_set (coro_current, (SV *)coro->hv); /* this will cause acroak in transfer_check */ |
1164 | load_perl (aTHX_ coro); |
1165 | load_perl (aTHX_ coro); |
1165 | |
1166 | |
1166 | coro_unwind_stacks (aTHX); |
1167 | coro_unwind_stacks (aTHX); |
1167 | coro_destruct_stacks (aTHX); |
1168 | coro_destruct_stacks (aTHX); |
1168 | |
1169 | |
… | |
… | |
1179 | svf [6] = (SV *)GvHV (PL_hintgv); |
1180 | svf [6] = (SV *)GvHV (PL_hintgv); |
1180 | svf [7] = PL_diehook; |
1181 | svf [7] = PL_diehook; |
1181 | svf [8] = PL_warnhook; |
1182 | svf [8] = PL_warnhook; |
1182 | assert (9 == sizeof (svf) / sizeof (*svf)); |
1183 | assert (9 == sizeof (svf) / sizeof (*svf)); |
1183 | |
1184 | |
|
|
1185 | SvRV_set (coro_current, (SV *)current->hv); |
1184 | load_perl (aTHX_ current); |
1186 | load_perl (aTHX_ current); |
1185 | } |
1187 | } |
1186 | |
1188 | |
1187 | { |
1189 | { |
1188 | unsigned int i; |
1190 | unsigned int i; |
… | |
… | |
1666 | #define TRANSFER(ta, force_cctx) transfer (aTHX_ (ta).prev, (ta).next, (force_cctx)) |
1668 | #define TRANSFER(ta, force_cctx) transfer (aTHX_ (ta).prev, (ta).next, (force_cctx)) |
1667 | #define TRANSFER_CHECK(ta) transfer_check (aTHX_ (ta).prev, (ta).next) |
1669 | #define TRANSFER_CHECK(ta) transfer_check (aTHX_ (ta).prev, (ta).next) |
1668 | |
1670 | |
1669 | /** high level stuff ********************************************************/ |
1671 | /** high level stuff ********************************************************/ |
1670 | |
1672 | |
1671 | static int |
1673 | static void |
1672 | coro_state_destroy (pTHX_ struct coro *coro) |
1674 | coro_state_destroy (pTHX_ struct coro *coro) |
1673 | { |
1675 | { |
1674 | if (coro->flags & CF_DESTROYED) |
1676 | if (coro->flags & CF_DESTROYED) |
1675 | return 0; |
1677 | return; |
1676 | |
1678 | |
|
|
1679 | /* this callback is reserved for slf functions needing to do cleanup */ |
1677 | if (coro->on_destroy && !PL_dirty) |
1680 | if (coro->on_destroy && !PL_dirty) |
1678 | coro->on_destroy (aTHX_ coro); |
1681 | coro->on_destroy (aTHX_ coro); |
1679 | |
1682 | |
1680 | /* |
1683 | /* |
1681 | * The on_destroy above most likely is from an SLF call. |
1684 | * The on_destroy above most likely is from an SLF call. |
… | |
… | |
1709 | cctx_destroy (coro->cctx); |
1712 | cctx_destroy (coro->cctx); |
1710 | SvREFCNT_dec (coro->startcv); |
1713 | SvREFCNT_dec (coro->startcv); |
1711 | SvREFCNT_dec (coro->args); |
1714 | SvREFCNT_dec (coro->args); |
1712 | SvREFCNT_dec (coro->swap_sv); |
1715 | SvREFCNT_dec (coro->swap_sv); |
1713 | SvREFCNT_dec (CORO_THROW); |
1716 | SvREFCNT_dec (CORO_THROW); |
1714 | |
|
|
1715 | return 1; |
|
|
1716 | } |
1717 | } |
1717 | |
1718 | |
1718 | static int |
1719 | static int |
1719 | coro_state_free (pTHX_ SV *sv, MAGIC *mg) |
1720 | coro_state_free (pTHX_ SV *sv, MAGIC *mg) |
1720 | { |
1721 | { |