ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/Coro/CoroAPI.h
Revision: 1.18
Committed: Fri May 23 00:27:06 2008 UTC (16 years, 5 months ago) by root
Content type: text/plain
Branch: MAIN
CVS Tags: rel-4_91, rel-4_748, rel-4_8, rel-4_9, rel-4_741, rel-4_743, rel-4_742, rel-4_744, rel-4_747, rel-4_74, rel-4_71, rel-4_72, rel-4_73, rel-4_802, rel-4_803, rel-4_801, rel-4_804, rel-4_479, rel-4_745, rel-4_901, rel-4_746, rel-4_911, rel-4_912
Changes since 1.17: +4 -1 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.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 pcg 1.5 #ifndef pTHX_
9     # define pTHX_
10     # define aTHX_
11     # define pTHX
12     # define aTHX
13     #endif
14    
15 root 1.9 /*struct coro;*/ /* opaque */
16 root 1.1
17 root 1.10 /* private structure, always use the provided macros below */
18 root 1.1 struct CoroAPI {
19     I32 ver;
20 root 1.15 I32 rev;
21     #define CORO_API_VERSION 6
22 root 1.18 #define CORO_API_REVISION 1
23 root 1.16 void (*transfer) (SV *prev_sv, SV *next_sv); /* Coro::State */
24 root 1.1
25 root 1.16 void (*schedule) (void); /* Coro */
26 root 1.12 int (*cede) (void);
27     int (*cede_notself) (void);
28 root 1.9 int (*ready) (SV *coro_sv);
29     int (*is_ready) (SV *coro_sv);
30 root 1.1 int *nready;
31 root 1.10 SV *current;
32 root 1.18
33     void (*readyhook) (void);
34 root 1.1 };
35    
36     static struct CoroAPI *GCoroAPI;
37    
38 root 1.11 /* public API macros */
39     #define CORO_TRANSFER(prev,next) GCoroAPI->transfer (aTHX_ (prev), (next))
40     #define CORO_SCHEDULE GCoroAPI->schedule ()
41     #define CORO_CEDE GCoroAPI->cede ()
42 root 1.12 #define CORO_CEDE_NOTSELF GCoroAPI->cede_notself ()
43 root 1.11 #define CORO_READY(coro) GCoroAPI->ready (coro)
44     #define CORO_IS_READY(coro) GCoroAPI->is_ready (coro)
45     #define CORO_NREADY (*GCoroAPI->nready)
46     #define CORO_CURRENT SvRV (GCoroAPI->current)
47 root 1.18 #define CORO_READYHOOK (GCoroAPI->readyhook)
48 root 1.1
49 root 1.17 #define I_CORO_API(YourName) \
50     STMT_START { \
51     SV *sv = perl_get_sv ("Coro::API", 0); \
52     if (!sv) croak ("Coro::API not found"); \
53     GCoroAPI = (struct CoroAPI*) SvIV (sv); \
54     if (GCoroAPI->ver != CORO_API_VERSION \
55     || GCoroAPI->rev < CORO_API_REVISION) \
56 root 1.16 croak ("Coro::API version mismatch (%d.%d vs. %d.%d) -- please recompile %s", \
57     GCoroAPI->ver, GCoroAPI->rev, CORO_API_VERSION, CORO_API_REVISION, YourName); \
58 root 1.1 } STMT_END
59    
60     #endif
61