… | |
… | |
31 | { |
31 | { |
32 | I32 ver; |
32 | I32 ver; |
33 | I32 rev; |
33 | I32 rev; |
34 | #define CORO_API_VERSION 7 |
34 | #define CORO_API_VERSION 7 |
35 | #define CORO_API_REVISION 0 |
35 | #define CORO_API_REVISION 0 |
36 | void (*transfer) (pTHX_ SV *prev_sv, SV *next_sv); /* Coro::State */ |
|
|
37 | |
36 | |
|
|
37 | /* Coro */ |
|
|
38 | int nready; |
|
|
39 | SV *current; |
|
|
40 | void (*readyhook) (void); |
|
|
41 | |
38 | void (*schedule) (pTHX); /* Coro */ |
42 | void (*schedule) (pTHX); |
39 | int (*cede) (pTHX); |
43 | int (*cede) (pTHX); |
40 | int (*cede_notself) (pTHX); |
44 | int (*cede_notself) (pTHX); |
41 | int (*ready) (pTHX_ SV *coro_sv); |
45 | int (*ready) (pTHX_ SV *coro_sv); |
42 | int (*is_ready) (pTHX_ SV *coro_sv); |
46 | int (*is_ready) (pTHX_ SV *coro_sv); |
43 | int nready; |
|
|
44 | SV *current; |
|
|
45 | |
47 | |
46 | void (*readyhook) (void); |
48 | /* Coro::State */ |
47 | void (*execute_slf) (pTHX_ struct CoroSLF *slf); |
49 | void (*transfer) (pTHX_ SV *prev_sv, SV *next_sv); /* Coro::State */ |
|
|
50 | void (*execute_slf) (pTHX_ CV *cv, const struct CoroSLF *slf, SV **arg, int nitems); |
|
|
51 | |
48 | }; |
52 | }; |
49 | |
53 | |
50 | static struct CoroAPI *GCoroAPI; |
54 | static struct CoroAPI *GCoroAPI; |
51 | |
55 | |
52 | /* public API macros */ |
56 | /* public API macros */ |
… | |
… | |
57 | #define CORO_READY(coro) GCoroAPI->ready (aTHX_ coro) |
61 | #define CORO_READY(coro) GCoroAPI->ready (aTHX_ coro) |
58 | #define CORO_IS_READY(coro) GCoroAPI->is_ready (coro) |
62 | #define CORO_IS_READY(coro) GCoroAPI->is_ready (coro) |
59 | #define CORO_NREADY GCoroAPI->nready |
63 | #define CORO_NREADY GCoroAPI->nready |
60 | #define CORO_CURRENT SvRV (GCoroAPI->current) |
64 | #define CORO_CURRENT SvRV (GCoroAPI->current) |
61 | #define CORO_READYHOOK GCoroAPI->readyhook |
65 | #define CORO_READYHOOK GCoroAPI->readyhook |
|
|
66 | |
62 | #define CORO_EXECUTE_SLF(slf) GCoroAPI->execute_slf (aTHX_ &(slf)) |
67 | #define CORO_EXECUTE_SLF(cv,slf,arg,nitems) GCoroAPI->execute_slf (aTHX_ (cv), &(slf), (arg), (nitems)) |
|
|
68 | #define CORO_EXECUTE_SLF_XS(slf) CORO_EXECUTE_SLF (cv, (slf), &ST (0), nitems) |
63 | |
69 | |
64 | #define I_CORO_API(YourName) \ |
70 | #define I_CORO_API(YourName) \ |
65 | STMT_START { \ |
71 | STMT_START { \ |
66 | SV *sv = perl_get_sv ("Coro::API", 0); \ |
72 | SV *sv = perl_get_sv ("Coro::API", 0); \ |
67 | if (!sv) croak ("Coro::API not found"); \ |
73 | if (!sv) croak ("Coro::API not found"); \ |