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.31 by root, Mon Jul 2 20:08:06 2012 UTC vs.
Revision 1.32 by root, Sun Jun 28 22:31:03 2015 UTC

33}; 33};
34 34
35/* needs to fill in the *frame */ 35/* needs to fill in the *frame */
36typedef void (*coro_slf_cb) (pTHX_ struct CoroSLF *frame, CV *cv, SV **arg, int items); 36typedef void (*coro_slf_cb) (pTHX_ struct CoroSLF *frame, CV *cv, SV **arg, int items);
37 37
38/* called on enter/leave */
39typedef void (*coro_enterleave_hook) (pTHX_ void *arg);
40
38/* private structure, always use the provided macros below */ 41/* private structure, always use the provided macros below */
39struct CoroAPI 42struct CoroAPI
40{ 43{
41 /* private */ 44 /* private */
42 I32 ver; 45 I32 ver;
43 I32 rev; 46 I32 rev;
44#define CORO_API_VERSION 7 /* reorder CoroSLF on change */ 47#define CORO_API_VERSION 7 /* reorder CoroSLF on change */
45#define CORO_API_REVISION 1 48#define CORO_API_REVISION 2
46 49
47 /* Coro */ 50 /* Coro */
48 int nready; 51 int nready;
49 SV *current; 52 SV *current;
50 SV *except; 53 SV *except;
59 62
60 /* Coro::State */ 63 /* Coro::State */
61 void (*transfer) (pTHX_ SV *prev_sv, SV *next_sv); /* Coro::State */ 64 void (*transfer) (pTHX_ SV *prev_sv, SV *next_sv); /* Coro::State */
62 65
63 /* SLF */ 66 /* SLF */
64 struct coro *(*sv_state) (pTHX_ SV *coro); 67 struct coro *(*sv_state) (pTHX_ SV *coro_sv);
65 void (*execute_slf) (pTHX_ CV *cv, coro_slf_cb init_cb, I32 ax); 68 void (*execute_slf) (pTHX_ CV *cv, coro_slf_cb init_cb, I32 ax);
66 69
67 /* public */ 70 /* public */
68 /* for use as CoroSLF.prepare */ 71 /* for use as CoroSLF.prepare */
69 void (*prepare_nop) (pTHX_ struct coro_transfer_args *ta); 72 void (*prepare_nop) (pTHX_ struct coro_transfer_args *ta);
70 void (*prepare_schedule) (pTHX_ struct coro_transfer_args *ta); 73 void (*prepare_schedule) (pTHX_ struct coro_transfer_args *ta);
71 void (*prepare_cede) (pTHX_ struct coro_transfer_args *ta); 74 void (*prepare_cede) (pTHX_ struct coro_transfer_args *ta);
72 void (*prepare_cede_notself) (pTHX_ struct coro_transfer_args *ta); 75 void (*prepare_cede_notself) (pTHX_ struct coro_transfer_args *ta);
76
77 /* private */
78 void (*enterleave_hook)(pTHX_ SV *coro_sv, coro_enterleave_hook enter, void *enter_arg, coro_enterleave_hook leave, void *leave_arg);
79 void (*enterleave_unhook)(pTHX_ SV *coro_sv, coro_enterleave_hook enter, coro_enterleave_hook leave);
80 void (*enterleave_scope_hook)(pTHX_ coro_enterleave_hook enter, void *enter_arg, coro_enterleave_hook leave, void *leave_arg); /* XS caller must LEAVE/ENTER */
73}; 81};
74 82
75static struct CoroAPI *GCoroAPI; 83static struct CoroAPI *GCoroAPI;
76 84
77/* public API macros */ 85/* public API macros */
89#define CORO_NREADY (GCoroAPI->nready) 97#define CORO_NREADY (GCoroAPI->nready)
90#define CORO_THROW (GCoroAPI->except) 98#define CORO_THROW (GCoroAPI->except)
91#define CORO_CURRENT SvRV (GCoroAPI->current) 99#define CORO_CURRENT SvRV (GCoroAPI->current)
92#define CORO_READYHOOK (GCoroAPI->readyhook) 100#define CORO_READYHOOK (GCoroAPI->readyhook)
93 101
102#define CORO_ENTERLEAVE_HOOK(coro,enter,enter_arg,leave,leave_arg) GCoroAPI->enterleave_hook (aTHX_ coro, enter, enter_arg, leave, leave_arg)
103#define CORO_ENTERLEAVE_UNHOOK(coro,enter,leave) GCoroAPI->enterleave_hook (aTHX_ coro, enter , leave )
104#define CORO_ENTERLEAVE_SCOPE_HOOK(enter,enter_arg,leave,leave_arg) GCoroAPI->enterleave_scope_hook (aTHX_ enter, enter_arg, leave, leave_arg)
105
94#define I_CORO_API(YourName) \ 106#define I_CORO_API(YourName) \
95STMT_START { \ 107STMT_START { \
96 SV *sv = perl_get_sv ("Coro::API", 0); \ 108 SV *sv = perl_get_sv ("Coro::API", 0); \
97 if (!sv) croak ("Coro::API not found"); \ 109 if (!sv) croak ("Coro::API not found"); \
98 GCoroAPI = (struct CoroAPI*) SvIV (sv); \ 110 GCoroAPI = (struct CoroAPI*) SvIV (sv); \

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines