… | |
… | |
17 | /* private structure, always use the provided macros below */ |
17 | /* private structure, always use the provided macros below */ |
18 | struct CoroAPI { |
18 | struct CoroAPI { |
19 | I32 ver; |
19 | I32 ver; |
20 | I32 rev; |
20 | I32 rev; |
21 | #define CORO_API_VERSION 6 |
21 | #define CORO_API_VERSION 6 |
22 | #define CORO_API_REVISION 0 |
22 | #define CORO_API_REVISION 1 |
23 | void (*transfer) (SV *prev_sv, SV *next_sv); /* Coro::State */ |
23 | void (*transfer) (SV *prev_sv, SV *next_sv); /* Coro::State */ |
24 | |
24 | |
25 | void (*schedule) (void); /* Coro */ |
25 | void (*schedule) (void); /* Coro */ |
26 | int (*cede) (void); |
26 | int (*cede) (void); |
27 | int (*cede_notself) (void); |
27 | int (*cede_notself) (void); |
28 | int (*ready) (SV *coro_sv); |
28 | int (*ready) (SV *coro_sv); |
29 | int (*is_ready) (SV *coro_sv); |
29 | int (*is_ready) (SV *coro_sv); |
30 | int *nready; |
30 | int *nready; |
31 | SV *current; |
31 | SV *current; |
|
|
32 | |
|
|
33 | void (*readyhook) (void); |
32 | }; |
34 | }; |
33 | |
35 | |
34 | static struct CoroAPI *GCoroAPI; |
36 | static struct CoroAPI *GCoroAPI; |
35 | |
37 | |
36 | /* public API macros */ |
38 | /* public API macros */ |
… | |
… | |
40 | #define CORO_CEDE_NOTSELF GCoroAPI->cede_notself () |
42 | #define CORO_CEDE_NOTSELF GCoroAPI->cede_notself () |
41 | #define CORO_READY(coro) GCoroAPI->ready (coro) |
43 | #define CORO_READY(coro) GCoroAPI->ready (coro) |
42 | #define CORO_IS_READY(coro) GCoroAPI->is_ready (coro) |
44 | #define CORO_IS_READY(coro) GCoroAPI->is_ready (coro) |
43 | #define CORO_NREADY (*GCoroAPI->nready) |
45 | #define CORO_NREADY (*GCoroAPI->nready) |
44 | #define CORO_CURRENT SvRV (GCoroAPI->current) |
46 | #define CORO_CURRENT SvRV (GCoroAPI->current) |
|
|
47 | #define CORO_READYHOOK (GCoroAPI->readyhook) |
45 | |
48 | |
46 | #define I_CORO_API(YourName) \ |
49 | #define I_CORO_API(YourName) \ |
47 | STMT_START { \ |
50 | STMT_START { \ |
48 | SV *sv = perl_get_sv ("Coro::API", 0); \ |
51 | SV *sv = perl_get_sv ("Coro::API", 0); \ |
49 | if (!sv) croak ("Coro::API not found"); \ |
52 | if (!sv) croak ("Coro::API not found"); \ |