ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev.h
(Generate patch)

Comparing libev/ev.h (file contents):
Revision 1.27 by root, Sat Nov 3 21:58:51 2007 UTC vs.
Revision 1.30 by root, Sun Nov 4 15:58:50 2007 UTC

42#endif 42#endif
43#ifndef EV_MAXPRI 43#ifndef EV_MAXPRI
44# define EV_MAXPRI +2 44# define EV_MAXPRI +2
45#endif 45#endif
46 46
47#ifndef EV_MULTIPLICITY
48# define EV_MULTIPLICITY 1
49#endif
50
51/* support multiple event loops? */
52#if EV_MULTIPLICITY
53struct ev_loop;
54# define EV_P struct ev_loop *loop
55# define EV_P_ EV_P,
56# define EV_A loop
57# define EV_A_ EV_A,
58#else
47#define EV_P void 59# define EV_P void
48#define EV_P_ 60# define EV_P_
49#define EV_A 61# define EV_A
50#define EV_A_ 62# define EV_A_
63#endif
51 64
52/* eventmask, revents, events... */ 65/* eventmask, revents, events... */
53#define EV_UNDEF -1 /* guaranteed to be invalid */ 66#define EV_UNDEF -1 /* guaranteed to be invalid */
54#define EV_NONE 0x00 67#define EV_NONE 0x00
55#define EV_READ 0x01 68#define EV_READ 0x01
143/* invoked when the given signal has been received */ 156/* invoked when the given signal has been received */
144/* revent EV_SIGNAL */ 157/* revent EV_SIGNAL */
145struct ev_signal 158struct ev_signal
146{ 159{
147 EV_WATCHER_LIST (ev_signal); 160 EV_WATCHER_LIST (ev_signal);
161#if EV_MULTIPLICITY
162 struct ev_loop *loop;
163#endif
148 164
149 int signum; /* ro */ 165 int signum; /* ro */
150}; 166};
151 167
152/* invoked when the nothing else needs to be done, keeps the process from blocking */ 168/* invoked when the nothing else needs to be done, keeps the process from blocking */
189#define EVMETHOD_EPOLL 4 205#define EVMETHOD_EPOLL 4
190#define EVMETHOD_KQUEUE 8 206#define EVMETHOD_KQUEUE 8
191#define EVMETHOD_DEVPOLL 16 /* NYI */ 207#define EVMETHOD_DEVPOLL 16 /* NYI */
192#define EVMETHOD_PORT 32 /* NYI */ 208#define EVMETHOD_PORT 32 /* NYI */
193#define EVMETHOD_ANY ~0 /* any method, do not consult env */ 209#define EVMETHOD_ANY ~0 /* any method, do not consult env */
210
194#if EV_PROTOTYPES 211#if EV_PROTOTYPES
195int ev_method (EV_P);
196int ev_init (EV_P_ int methods); /* returns ev_method */
197int ev_version_major (void); 212int ev_version_major (void);
198int ev_version_minor (void); 213int ev_version_minor (void);
199 214
200/* these three calls are suitable for plugging into pthread_atfork */
201void ev_fork_prepare (void);
202void ev_fork_parent (void);
203void ev_fork_child (void);
204
205ev_tstamp ev_time (void); 215ev_tstamp ev_time (void);
216
217# if EV_MULTIPLICITY
218/* the default loop is the only one that handles signals and child watchers */
219/* you can call this as often as you like */
220struct ev_loop *ev_default_loop (int methods); /* returns default loop */
221
222/* create and destroy alternative loops that don't handle signals */
223struct ev_loop *ev_loop_new (int methods);
224void ev_loop_destroy (EV_P);
225void ev_loop_fork (EV_P);
226# else
227int ev_default_loop (int methods); /* returns true when successful */
228# endif
229
230void ev_default_destroy (void); /* destroy the default loop */
231/* this needs to be called after fork, to duplicate the default loop */
232/* if you create alternative loops you have to call ev_loop_fork on them */
233/* you can call it in either the parent or the child */
234/* you can actually call it at any time, anywhere :) */
235void ev_default_fork (void);
236
237int ev_method (EV_P);
206#endif 238#endif
207 239
208#define EVLOOP_NONBLOCK 1 /* do not block/wait */ 240#define EVLOOP_NONBLOCK 1 /* do not block/wait */
209#define EVLOOP_ONESHOT 2 /* block *once* only */ 241#define EVLOOP_ONESHOT 2 /* block *once* only */
242#define EVUNLOOP_ONCE 1 /* unloop once */
243#define EVUNLOOP_ALL 2 /* unloop all loops */
244
210#if EV_PROTOTYPES 245#if EV_PROTOTYPES
211void ev_loop (EV_P_ int flags); 246void ev_loop (EV_P_ int flags);
212void ev_unloop (EV_P_ int status); /* set to 1 to break out of event loop, set to 2 to break out of all event loops */ 247void ev_unloop (EV_P_ int how); /* set to 1 to break out of event loop, set to 2 to break out of all event loops */
213 248
214ev_tstamp ev_now (EV_P); /* time w.r.t. timers and the eventloop, updated after each poll */ 249ev_tstamp ev_now (EV_P); /* time w.r.t. timers and the eventloop, updated after each poll */
215 250
216/* 251/*
217 * ref/unref can be used to add or remove a refcount on the mainloop. every watcher 252 * ref/unref can be used to add or remove a refcount on the mainloop. every watcher
257void ev_io_start (EV_P_ struct ev_io *w); 292void ev_io_start (EV_P_ struct ev_io *w);
258void ev_io_stop (EV_P_ struct ev_io *w); 293void ev_io_stop (EV_P_ struct ev_io *w);
259 294
260void ev_timer_start (EV_P_ struct ev_timer *w); 295void ev_timer_start (EV_P_ struct ev_timer *w);
261void ev_timer_stop (EV_P_ struct ev_timer *w); 296void ev_timer_stop (EV_P_ struct ev_timer *w);
262void ev_timer_again (EV_P_ struct ev_timer *w); /* stops if active and no repeat, restarts if active and repeating, starts if inactive and repeating */ 297/* stops if active and no repeat, restarts if active and repeating, starts if inactive and repeating */
298void ev_timer_again (EV_P_ struct ev_timer *w);
263 299
264void ev_periodic_start (EV_P_ struct ev_periodic *w); 300void ev_periodic_start (EV_P_ struct ev_periodic *w);
265void ev_periodic_stop (EV_P_ struct ev_periodic *w); 301void ev_periodic_stop (EV_P_ struct ev_periodic *w);
266 302
303void ev_idle_start (EV_P_ struct ev_idle *w);
304void ev_idle_stop (EV_P_ struct ev_idle *w);
305
306void ev_prepare_start (EV_P_ struct ev_prepare *w);
307void ev_prepare_stop (EV_P_ struct ev_prepare *w);
308
309void ev_check_start (EV_P_ struct ev_check *w);
310void ev_check_stop (EV_P_ struct ev_check *w);
311
312/* only supported in the default loop */
267void ev_signal_start (EV_P_ struct ev_signal *w); 313void ev_signal_start (EV_P_ struct ev_signal *w);
268void ev_signal_stop (EV_P_ struct ev_signal *w); 314void ev_signal_stop (EV_P_ struct ev_signal *w);
269 315
270void ev_idle_start (EV_P_ struct ev_idle *w); 316/* only supported in the default loop */
271void ev_idle_stop (EV_P_ struct ev_idle *w);
272
273void ev_prepare_start (EV_P_ struct ev_prepare *w);
274void ev_prepare_stop (EV_P_ struct ev_prepare *w);
275
276void ev_check_start (EV_P_ struct ev_check *w);
277void ev_check_stop (EV_P_ struct ev_check *w);
278
279void ev_child_start (EV_P_ struct ev_child *w); 317void ev_child_start (EV_P_ struct ev_child *w);
280void ev_child_stop (EV_P_ struct ev_child *w); 318void ev_child_stop (EV_P_ struct ev_child *w);
281#endif 319#endif
282 320
283#ifdef __cplusplus 321#ifdef __cplusplus

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines