ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/EV/EV/EVAPI.h
Revision: 1.6
Committed: Wed Oct 31 11:52:12 2007 UTC (16 years, 7 months ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.5: +1 -0 lines
Log Message:
*** empty log message ***

File Contents

# Content
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 /* you MUST NOT call any of the libev functions, ALWAYS use GEVAPI */
16 #include <ev.h>
17
18 struct EVAPI {
19 I32 ver;
20 I32 rev;
21 #define EV_API_VERSION 2
22 #define EV_API_REVISION 0
23
24 /* wait for a single event, without registering an event watcher */
25 /* if timeout is < 0, do wait indefinitely */
26 void (*once)(int fd, short events, double timeout, void (*cb)(int, short, void *), void *arg);
27
28 /* perl fh or fd int to fd */
29 int (*sv_fileno) (SV *fh);
30 /* signal number/name to signum */
31 int (*sv_signum) (SV *fh);
32
33 /* libev global variables (note: references!) */
34 ev_tstamp *now;
35 int *method;
36 int *loop_done;
37
38 /* same as libev functions */
39 ev_tstamp (*(time))(void);
40 void (*loop)(int flags);
41 void (*io_start)(struct ev_io *);
42 void (*io_stop) (struct ev_io *);
43 void (*timer_start)(struct ev_timer *);
44 void (*timer_stop) (struct ev_timer *);
45 void (*timer_again)(struct ev_timer *);
46 void (*periodic_start)(struct ev_periodic *);
47 void (*periodic_stop) (struct ev_periodic *);
48 void (*signal_start)(struct ev_signal *);
49 void (*signal_stop) (struct ev_signal *);
50 void (*idle_start)(struct ev_idle *);
51 void (*idle_stop) (struct ev_idle *);
52 void (*check_start)(struct ev_check *);
53 void (*check_stop) (struct ev_check *);
54 };
55
56 /*
57 * usage examples:
58 *
59 * now = GEVAPI->now ();
60 * GEVAPI->once (5, EV_READ, 60, my_cb, (void *)mysv);
61 */
62
63 static struct EVAPI *GEVAPI;
64
65 #define I_EV_API(YourName) \
66 STMT_START { \
67 SV *sv = perl_get_sv ("EV::API", 0); \
68 if (!sv) croak ("EV::API not found"); \
69 GEVAPI = (struct EVAPI*) SvIV (sv); \
70 if (GEVAPI->ver != EV_API_VERSION \
71 || GEVAPI->rev < EV_API_REVISION) \
72 croak ("EV::API version mismatch (%d.%d vs. %d.%d) -- please recompile %s", \
73 GEVAPI->ver, GEVAPI->rev, EV_API_VERSION, EV_API_REVISION, YourName); \
74 } STMT_END
75
76 #endif
77