… | |
… | |
1275 | /* somebody or something will hit me for both perl_run and PL_restartop */ |
1275 | /* somebody or something will hit me for both perl_run and PL_restartop */ |
1276 | PL_restartop = PL_op; |
1276 | PL_restartop = PL_op; |
1277 | perl_run (PL_curinterp); |
1277 | perl_run (PL_curinterp); |
1278 | /* |
1278 | /* |
1279 | * Unfortunately, there is no way to get at the return values of the |
1279 | * Unfortunately, there is no way to get at the return values of the |
1280 | * coro body here, as perl_run destroys these |
1280 | * coro body here, as perl_run destroys these. Likewise, we cannot catch |
|
|
1281 | * runtime errors here, as this is just a random interpreter, not a thread. |
1281 | */ |
1282 | */ |
1282 | |
1283 | |
1283 | /* |
1284 | /* |
1284 | * If perl-run returns we assume exit() was being called or the coro |
1285 | * If perl-run returns we assume exit() was being called or the coro |
1285 | * fell off the end, which seems to be the only valid (non-bug) |
1286 | * fell off the end, which seems to be the only valid (non-bug) |
… | |
… | |
1668 | } |
1669 | } |
1669 | |
1670 | |
1670 | return 0; |
1671 | return 0; |
1671 | } |
1672 | } |
1672 | |
1673 | |
|
|
1674 | static void |
|
|
1675 | invoke_sv_ready_hook_helper (void) |
|
|
1676 | { |
|
|
1677 | dTHX; |
|
|
1678 | dSP; |
|
|
1679 | |
|
|
1680 | ENTER; |
|
|
1681 | SAVETMPS; |
|
|
1682 | |
|
|
1683 | PUSHMARK (SP); |
|
|
1684 | PUTBACK; |
|
|
1685 | call_sv (coro_readyhook, G_VOID | G_DISCARD); |
|
|
1686 | |
|
|
1687 | FREETMPS; |
|
|
1688 | LEAVE; |
|
|
1689 | } |
|
|
1690 | |
1673 | static int |
1691 | static int |
1674 | api_ready (pTHX_ SV *coro_sv) |
1692 | api_ready (pTHX_ SV *coro_sv) |
1675 | { |
1693 | { |
1676 | struct coro *coro; |
|
|
1677 | SV *sv_hook; |
|
|
1678 | void (*xs_hook)(void); |
|
|
1679 | |
|
|
1680 | coro = SvSTATE (coro_sv); |
1694 | struct coro *coro = SvSTATE (coro_sv); |
1681 | |
1695 | |
1682 | if (coro->flags & CF_READY) |
1696 | if (coro->flags & CF_READY) |
1683 | return 0; |
1697 | return 0; |
1684 | |
1698 | |
1685 | coro->flags |= CF_READY; |
1699 | coro->flags |= CF_READY; |
1686 | |
1700 | |
1687 | sv_hook = coro_nready ? 0 : coro_readyhook; |
|
|
1688 | xs_hook = coro_nready ? 0 : coroapi.readyhook; |
|
|
1689 | |
|
|
1690 | coro_enq (aTHX_ coro); |
1701 | coro_enq (aTHX_ coro); |
1691 | ++coro_nready; |
|
|
1692 | |
1702 | |
1693 | if (sv_hook) |
1703 | if (!coro_nready++) |
1694 | { |
1704 | if (coroapi.readyhook) |
1695 | dSP; |
1705 | coroapi.readyhook (); |
1696 | |
|
|
1697 | ENTER; |
|
|
1698 | SAVETMPS; |
|
|
1699 | |
|
|
1700 | PUSHMARK (SP); |
|
|
1701 | PUTBACK; |
|
|
1702 | call_sv (sv_hook, G_VOID | G_DISCARD); |
|
|
1703 | |
|
|
1704 | FREETMPS; |
|
|
1705 | LEAVE; |
|
|
1706 | } |
|
|
1707 | |
|
|
1708 | if (xs_hook) |
|
|
1709 | xs_hook (); |
|
|
1710 | |
1706 | |
1711 | return 1; |
1707 | return 1; |
1712 | } |
1708 | } |
1713 | |
1709 | |
1714 | static int |
1710 | static int |
… | |
… | |
3394 | _set_readyhook (SV *hook) |
3390 | _set_readyhook (SV *hook) |
3395 | PROTOTYPE: $ |
3391 | PROTOTYPE: $ |
3396 | CODE: |
3392 | CODE: |
3397 | SvREFCNT_dec (coro_readyhook); |
3393 | SvREFCNT_dec (coro_readyhook); |
3398 | SvGETMAGIC (hook); |
3394 | SvGETMAGIC (hook); |
|
|
3395 | if (SvOK (hook)) |
|
|
3396 | { |
3399 | coro_readyhook = SvOK (hook) ? newSVsv (hook) : 0; |
3397 | coro_readyhook = newSVsv (hook); |
|
|
3398 | CORO_READYHOOK = invoke_sv_ready_hook_helper; |
|
|
3399 | } |
|
|
3400 | else |
|
|
3401 | { |
|
|
3402 | coro_readyhook = 0; |
|
|
3403 | CORO_READYHOOK = 0; |
|
|
3404 | } |
3400 | |
3405 | |
3401 | int |
3406 | int |
3402 | prio (Coro::State coro, int newprio = 0) |
3407 | prio (Coro::State coro, int newprio = 0) |
3403 | PROTOTYPE: $;$ |
3408 | PROTOTYPE: $;$ |
3404 | ALIAS: |
3409 | ALIAS: |