ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/Coro/CoroAPI.h
Revision: 1.14
Committed: Wed Oct 3 01:48:06 2007 UTC (17 years, 1 month ago) by root
Content type: text/plain
Branch: MAIN
CVS Tags: rel-4_0, rel-4_01, rel-4_03, rel-4_02
Changes since 1.13: +1 -19 lines
Log Message:
temporary check-in, non-working version

File Contents

# Content
1 #ifndef CORO_API_H
2 #define CORO_API_H
3
4 #include "EXTERN.h"
5 #include "perl.h"
6 #include "XSUB.h"
7
8 #ifndef pTHX_
9 # define pTHX_
10 # define aTHX_
11 # define pTHX
12 # define aTHX
13 #endif
14
15 /*struct coro;*/ /* opaque */
16
17 /* private structure, always use the provided macros below */
18 struct CoroAPI {
19 I32 ver;
20 #define CORO_API_VERSION 5
21 #define CORO_API_REVISION 0
22
23 /* internal */
24 /*struct coro *(*sv_to_coro)(SV *arg, const char *funcname, const char *varname);*/
25
26 /* private API, Coro::State */
27 void (*transfer) (SV *prev_sv, SV *next_sv);
28
29 /* private API, Coro */
30 void (*schedule) (void);
31 int (*cede) (void);
32 int (*cede_notself) (void);
33 int (*ready) (SV *coro_sv);
34 int (*is_ready) (SV *coro_sv);
35 int *nready;
36 SV *current;
37 };
38
39 static struct CoroAPI *GCoroAPI;
40
41 /* public API macros */
42 #define CORO_TRANSFER(prev,next) GCoroAPI->transfer (aTHX_ (prev), (next))
43 #define CORO_SCHEDULE GCoroAPI->schedule ()
44 #define CORO_CEDE GCoroAPI->cede ()
45 #define CORO_CEDE_NOTSELF GCoroAPI->cede_notself ()
46 #define CORO_READY(coro) GCoroAPI->ready (coro)
47 #define CORO_IS_READY(coro) GCoroAPI->is_ready (coro)
48 #define CORO_NREADY (*GCoroAPI->nready)
49 #define CORO_CURRENT SvRV (GCoroAPI->current)
50
51 #define I_CORO_API(YourName) \
52 STMT_START { \
53 SV *sv = perl_get_sv("Coro::API",0); \
54 if (!sv) croak("Coro::API not found"); \
55 GCoroAPI = (struct CoroAPI*) SvIV(sv); \
56 if (GCoroAPI->ver != CORO_API_VERSION) { \
57 croak("Coro::API version mismatch (%d != %d) -- please recompile %s", \
58 GCoroAPI->ver, CORO_API_VERSION, YourName); \
59 } \
60 } STMT_END
61
62 #endif
63