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.10 by root, Fri Dec 1 19:41:06 2006 UTC vs.
Revision 1.11 by root, Mon Dec 4 13:47:56 2006 UTC

11# define pTHX 11# define pTHX
12# define aTHX 12# define aTHX
13#endif 13#endif
14 14
15/* perl-related */ 15/* perl-related */
16#define TRANSFER_SAVE_DEFAV 0x00000001 /* @_ */ 16#define CORO_SAVE_DEFAV 0x00000001 /* @_ */
17#define TRANSFER_SAVE_DEFSV 0x00000002 /* $_ */ 17#define CORO_SAVE_DEFSV 0x00000002 /* $_ */
18#define TRANSFER_SAVE_ERRSV 0x00000004 /* $@ */ 18#define CORO_SAVE_ERRSV 0x00000004 /* $@ */
19#define CORO_SAVE_IRSSV 0x00000008 /* $/ */
19 20
20#define TRANSFER_SAVE_ALL ( TRANSFER_SAVE_DEFAV \ 21#define CORO_SAVE_ALL ( CORO_SAVE_DEFAV \
21 | TRANSFER_SAVE_DEFSV \ 22 | CORO_SAVE_DEFSV \
22 | TRANSFER_SAVE_ERRSV ) 23 | CORO_SAVE_ERRSV \
24 | CORO_SAVE_IRSSV )
23 25
24/*struct coro;*/ /* opaque */ 26/*struct coro;*/ /* opaque */
25 27
26/* private structure, always use the provided macros below */ 28/* private structure, always use the provided macros below */
27struct CoroAPI { 29struct CoroAPI {
28 I32 ver; 30 I32 ver;
29#define CORO_API_VERSION 2 31#define CORO_API_VERSION 3
30#define CORO_API_REVISION 0 32#define CORO_API_REVISION 0
31 33
32 /* internal */ 34 /* internal */
33 /*struct coro *(*sv_to_coro)(SV *arg, const char *funcname, const char *varname);*/ 35 /*struct coro *(*sv_to_coro)(SV *arg, const char *funcname, const char *varname);*/
34 36
35 /* public API, Coro::State */ 37 /* private API, Coro::State */
36 void (*transfer) (SV *prev, SV *next, int flags); 38 void (*transfer) (SV *prev_sv, SV *next_sv);
39 int (*save) (SV *coro_sv, int new_save);
37 40
38 /* public API, Coro */ 41 /* private API, Coro */
39 void (*schedule) (void); 42 void (*schedule) (void);
40 void (*cede) (void); 43 void (*cede) (void);
41 int (*ready) (SV *coro_sv); 44 int (*ready) (SV *coro_sv);
42 int (*is_ready) (SV *coro_sv); 45 int (*is_ready) (SV *coro_sv);
43 int *nready; 46 int *nready;
44 SV *current; 47 SV *current;
45}; 48};
46 49
47static struct CoroAPI *GCoroAPI; 50static struct CoroAPI *GCoroAPI;
48 51
52/* public API macros */
49#define CORO_TRANSFER(prev,next,flags) GCoroAPI->transfer (aTHX_ (prev), (next), (flags)) 53#define CORO_TRANSFER(prev,next) GCoroAPI->transfer (aTHX_ (prev), (next))
50#define CORO_SCHEDULE GCoroAPI->schedule () 54#define CORO_SCHEDULE GCoroAPI->schedule ()
51#define CORO_CEDE GCoroAPI->cede () 55#define CORO_CEDE GCoroAPI->cede ()
52#define CORO_READY(coro) GCoroAPI->ready (coro) 56#define CORO_READY(coro) GCoroAPI->ready (coro)
53#define CORO_IS_READY(coro) GCoroAPI->is_ready (coro) 57#define CORO_IS_READY(coro) GCoroAPI->is_ready (coro)
54#define CORO_NREADY (*GCoroAPI->nready) 58#define CORO_NREADY (*GCoroAPI->nready)
55#define CORO_CURRENT SvRV (GCoroAPI->current) 59#define CORO_CURRENT SvRV (GCoroAPI->current)
60#define CORO_GET_SAVE(coro) GCoroAPI->save ((coro), -1)
61#define CORO_SET_SAVE(coro,save) GCoroAPI->save ((coro), (save))
56 62
57#define I_CORO_API(YourName) \ 63#define I_CORO_API(YourName) \
58STMT_START { \ 64STMT_START { \
59 SV *sv = perl_get_sv("Coro::API",0); \ 65 SV *sv = perl_get_sv("Coro::API",0); \
60 if (!sv) croak("Coro::API not found"); \ 66 if (!sv) croak("Coro::API not found"); \

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines