ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/EV/EV/EVAPI.h
Revision: 1.3
Committed: Mon Oct 29 18:33:02 2007 UTC (16 years, 7 months ago) by root
Content type: text/plain
Branch: MAIN
CVS Tags: rel-0_03
Changes since 1.2: +3 -0 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 #ifndef EV_API_H
2     #define EV_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     #include <event.h>
16    
17     struct EVAPI {
18     I32 ver;
19     I32 rev;
20 root 1.2 #define EV_API_VERSION 1
21 root 1.1 #define EV_API_REVISION 0
22    
23 root 1.2 /* return the current wallclock time */
24 root 1.1 double (*now)(void);
25 root 1.2
26     /* wait for a single event, without registering an event watcher */
27     /* if timeout is < 0, do wait indefinitely */
28 root 1.1 void (*once)(int fd, short events, double timeout, void (*cb)(int, short, void *), void *arg);
29 root 1.3
30     /* same as event_loop */
31     int (*loop)(int flags);
32 root 1.1 };
33    
34 root 1.2 /*
35     * usage examples:
36     *
37     * now = GEVAPI->now ();
38     * GEVAPI->once (5, EV_READ, 60, my_cb, (void *)mysv);
39     */
40    
41 root 1.1 static struct EVAPI *GEVAPI;
42    
43     #define I_EV_API(YourName) \
44     STMT_START { \
45     SV *sv = perl_get_sv ("EV::API", 0); \
46     if (!sv) croak ("EV::API not found"); \
47     GEVAPI = (struct CoroAPI*) SvIV (sv); \
48     if (GEVAPI->ver != EV_API_VERSION \
49     || GEVAPI->rev < EV_API_REVISION) \
50     croak ("EV::API version mismatch (%d.%d vs. %d.%d) -- please recompile %s", \
51     GEVAPI->ver, GEVAPI->rev, EV_API_VERSION, EV_API_REVISION, YourName); \
52     } STMT_END
53    
54     #endif
55