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.6 by root, Sat Aug 20 00:49:42 2005 UTC vs.
Revision 1.10 by root, Fri Dec 1 19:41:06 2006 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines