ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/EV/EV/EVAPI.h
Revision: 1.2
Committed: Mon Oct 29 08:51:44 2007 UTC (16 years, 7 months ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.1: +12 -2 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     };
30    
31 root 1.2 /*
32     * usage examples:
33     *
34     * now = GEVAPI->now ();
35     * GEVAPI->once (5, EV_READ, 60, my_cb, (void *)mysv);
36     */
37    
38 root 1.1 static struct EVAPI *GEVAPI;
39    
40     #define I_EV_API(YourName) \
41     STMT_START { \
42     SV *sv = perl_get_sv ("EV::API", 0); \
43     if (!sv) croak ("EV::API not found"); \
44     GEVAPI = (struct CoroAPI*) SvIV (sv); \
45     if (GEVAPI->ver != EV_API_VERSION \
46     || GEVAPI->rev < EV_API_REVISION) \
47     croak ("EV::API version mismatch (%d.%d vs. %d.%d) -- please recompile %s", \
48     GEVAPI->ver, GEVAPI->rev, EV_API_VERSION, EV_API_REVISION, YourName); \
49     } STMT_END
50    
51     #endif
52