ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/Coro/CoroAPI.h
(Generate patch)

Comparing Coro/Coro/CoroAPI.h (file contents):
Revision 1.20 by root, Fri Nov 14 07:35:32 2008 UTC vs.
Revision 1.21 by root, Fri Nov 14 20:35:49 2008 UTC

10# define aTHX_ 10# define aTHX_
11# define pTHX 11# define pTHX
12# define aTHX 12# define aTHX
13#endif 13#endif
14 14
15/*struct coro;*/ /* opaque */ 15/* C-level coroutine struct, opaque, not used much */
16struct coro;
16 17
17enum { 18/* used for schedule-like-function prepares */
18 CORO_SLF_SCHEDULE = 3, 19struct coro_transfer_args
19 CORO_SLF_CEDE = 4, 20{
20 CORO_SLF_CEDE_NOTSELF = 5 21 struct coro *prev, *next;
21}; 22};
22 23
23struct CoroSLF 24struct CoroSLF
24{ 25{
25 int (*prepare) (pTHX_ SV **arg, int items); /* returns CORO_SLF_* */ 26 void (*init) (pTHX_ SV **arg, int items); /* returns CORO_SLF_* */
27 void (*prepare) (struct coro_transfer_args *ta);
26 int (*check) (pTHX); /* returns repeat-flag */ 28 int (*check) (pTHX); /* returns repeat-flag, may be zero */
27}; 29};
28 30
29/* private structure, always use the provided macros below */ 31/* private structure, always use the provided macros below */
30struct CoroAPI 32struct CoroAPI
31{ 33{
46 int (*is_ready) (pTHX_ SV *coro_sv); 48 int (*is_ready) (pTHX_ SV *coro_sv);
47 49
48 /* Coro::State */ 50 /* Coro::State */
49 void (*transfer) (pTHX_ SV *prev_sv, SV *next_sv); /* Coro::State */ 51 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); 52 void (*execute_slf) (pTHX_ CV *cv, const struct CoroSLF *slf, SV **arg, int nitems);
51 53 struct coro *(*sv_state) (pTHX_ SV *coro);
54 void *slf_data;
52}; 55};
53 56
54static struct CoroAPI *GCoroAPI; 57static struct CoroAPI *GCoroAPI;
55 58
56/* public API macros */ 59/* public API macros */
58#define CORO_SCHEDULE GCoroAPI->schedule (aTHX) 61#define CORO_SCHEDULE GCoroAPI->schedule (aTHX)
59#define CORO_CEDE GCoroAPI->cede (aTHX) 62#define CORO_CEDE GCoroAPI->cede (aTHX)
60#define CORO_CEDE_NOTSELF GCoroAPI->cede_notself (aTHX) 63#define CORO_CEDE_NOTSELF GCoroAPI->cede_notself (aTHX)
61#define CORO_READY(coro) GCoroAPI->ready (aTHX_ coro) 64#define CORO_READY(coro) GCoroAPI->ready (aTHX_ coro)
62#define CORO_IS_READY(coro) GCoroAPI->is_ready (coro) 65#define CORO_IS_READY(coro) GCoroAPI->is_ready (coro)
63#define CORO_NREADY GCoroAPI->nready 66#define CORO_NREADY (GCoroAPI->nready)
64#define CORO_CURRENT SvRV (GCoroAPI->current) 67#define CORO_CURRENT (SvRV (GCoroAPI->current))
65#define CORO_READYHOOK GCoroAPI->readyhook 68#define CORO_READYHOOK (GCoroAPI->readyhook)
66 69
67#define CORO_EXECUTE_SLF(cv,slf,arg,nitems) GCoroAPI->execute_slf (aTHX_ (cv), &(slf), (arg), (nitems)) 70#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) 71#define CORO_EXECUTE_SLF_XS(slf) CORO_EXECUTE_SLF (cv, (slf), &ST (0), nitems)
72
73#define CORO_SV_STATE(coro) GCoroAPI->sv_state (aTHX_ (coro))
74
75#define CORO_SLF_DATA (GCoroAPI->slf_data)
69 76
70#define I_CORO_API(YourName) \ 77#define I_CORO_API(YourName) \
71STMT_START { \ 78STMT_START { \
72 SV *sv = perl_get_sv ("Coro::API", 0); \ 79 SV *sv = perl_get_sv ("Coro::API", 0); \
73 if (!sv) croak ("Coro::API not found"); \ 80 if (!sv) croak ("Coro::API not found"); \

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines