… | |
… | |
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 0 |
|
|
23 | void (*transfer) (SV *prev_sv, SV *next_sv); /* Coro::State */ |
23 | |
24 | |
24 | /* internal */ |
|
|
25 | /*struct coro *(*sv_to_coro)(SV *arg, const char *funcname, const char *varname);*/ |
|
|
26 | |
|
|
27 | /* private API, Coro::State */ |
|
|
28 | void (*transfer) (SV *prev_sv, SV *next_sv); |
|
|
29 | |
|
|
30 | /* private API, Coro */ |
|
|
31 | void (*schedule) (void); |
25 | void (*schedule) (void); /* Coro */ |
32 | int (*cede) (void); |
26 | int (*cede) (void); |
33 | int (*cede_notself) (void); |
27 | int (*cede_notself) (void); |
34 | int (*ready) (SV *coro_sv); |
28 | int (*ready) (SV *coro_sv); |
35 | int (*is_ready) (SV *coro_sv); |
29 | int (*is_ready) (SV *coro_sv); |
36 | int *nready; |
30 | int *nready; |
37 | SV *current; |
31 | SV *current; |
38 | |
32 | |
39 | SV *(*coro_event_next)(SV *watcher, int cancel, int wantev); |
33 | SV *(*coro_event_next)(SV *watcher, int cancel, int wantev); /* Coro::Event::next */ |
40 | }; |
34 | }; |
41 | |
35 | |
42 | static struct CoroAPI *GCoroAPI; |
36 | static struct CoroAPI *GCoroAPI; |
43 | |
37 | |
44 | /* public API macros */ |
38 | /* public API macros */ |
… | |
… | |
51 | #define CORO_NREADY (*GCoroAPI->nready) |
45 | #define CORO_NREADY (*GCoroAPI->nready) |
52 | #define CORO_CURRENT SvRV (GCoroAPI->current) |
46 | #define CORO_CURRENT SvRV (GCoroAPI->current) |
53 | |
47 | |
54 | #define I_CORO_API(YourName) \ |
48 | #define I_CORO_API(YourName) \ |
55 | STMT_START { \ |
49 | STMT_START { \ |
56 | SV *sv = perl_get_sv("Coro::API",0); \ |
50 | SV *sv = perl_get_sv ("Coro::API", 0); \ |
57 | if (!sv) croak("Coro::API not found"); \ |
51 | if (!sv) croak ("Coro::API not found"); \ |
58 | GCoroAPI = (struct CoroAPI*) SvIV(sv); \ |
52 | GCoroAPI = (struct CoroAPI*) SvIV (sv); \ |
59 | if (GCoroAPI->ver != CORO_API_VERSION) \ |
53 | if (GCoroAPI->ver != CORO_API_VERSION \ |
60 | croak("Coro::API version mismatch (%d != %d) -- please recompile %s", \ |
|
|
61 | GCoroAPI->ver, CORO_API_VERSION, YourName); \ |
|
|
62 | if (GCoroAPI->rev < CORO_API_REVISION) \ |
54 | || GCoroAPI->rev < CORO_API_REVISION) \ |
63 | croak("Coro::API revision outdated (%d != %d) -- please recompile %s", \ |
55 | croak ("Coro::API version mismatch (%d.%d vs. %d.%d) -- please recompile %s", \ |
64 | GCoroAPI->rev, CORO_API_REVISION, YourName); \ |
56 | GCoroAPI->ver, GCoroAPI->rev, CORO_API_VERSION, CORO_API_REVISION, YourName); \ |
65 | } STMT_END |
57 | } STMT_END |
66 | |
58 | |
67 | #endif |
59 | #endif |
68 | |
60 | |