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

Comparing libev/ev.h (file contents):
Revision 1.28 by root, Sat Nov 3 22:10:39 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
47/* support multiple event loops? */ 51/* support multiple event loops? */
48#ifdef EV_MULTIPLICITY 52#if EV_MULTIPLICITY
49struct ev_loop; 53struct ev_loop;
50# define EV_P struct ev_loop *loop 54# define EV_P struct ev_loop *loop
51# define EV_P_ EV_P, 55# define EV_P_ EV_P,
52# define EV_A loop 56# define EV_A loop
53# define EV_A_ EV_A, 57# define EV_A_ EV_A,
54#else 58#else
55# define EV_P void 59# define EV_P void
56# define EV_P_ 60# define EV_P_
57# define EV_A 61# define EV_A
58# define EV_A_ 62# define EV_A_
59
60#endif 63#endif
61 64
62/* eventmask, revents, events... */ 65/* eventmask, revents, events... */
63#define EV_UNDEF -1 /* guaranteed to be invalid */ 66#define EV_UNDEF -1 /* guaranteed to be invalid */
64#define EV_NONE 0x00 67#define EV_NONE 0x00
153/* invoked when the given signal has been received */ 156/* invoked when the given signal has been received */
154/* revent EV_SIGNAL */ 157/* revent EV_SIGNAL */
155struct ev_signal 158struct ev_signal
156{ 159{
157 EV_WATCHER_LIST (ev_signal); 160 EV_WATCHER_LIST (ev_signal);
161#if EV_MULTIPLICITY
162 struct ev_loop *loop;
163#endif
158 164
159 int signum; /* ro */ 165 int signum; /* ro */
160}; 166};
161 167
162/* 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 */
199#define EVMETHOD_EPOLL 4 205#define EVMETHOD_EPOLL 4
200#define EVMETHOD_KQUEUE 8 206#define EVMETHOD_KQUEUE 8
201#define EVMETHOD_DEVPOLL 16 /* NYI */ 207#define EVMETHOD_DEVPOLL 16 /* NYI */
202#define EVMETHOD_PORT 32 /* NYI */ 208#define EVMETHOD_PORT 32 /* NYI */
203#define EVMETHOD_ANY ~0 /* any method, do not consult env */ 209#define EVMETHOD_ANY ~0 /* any method, do not consult env */
210
204#if EV_PROTOTYPES 211#if EV_PROTOTYPES
205int ev_method (EV_P);
206int ev_init (EV_P_ int methods); /* returns ev_method */
207int ev_version_major (void); 212int ev_version_major (void);
208int ev_version_minor (void); 213int ev_version_minor (void);
209 214
210/* these three calls are suitable for plugging into pthread_atfork */
211void ev_fork_prepare (void);
212void ev_fork_parent (void);
213void ev_fork_child (void);
214
215ev_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);
216#endif 238#endif
217 239
218#define EVLOOP_NONBLOCK 1 /* do not block/wait */ 240#define EVLOOP_NONBLOCK 1 /* do not block/wait */
219#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
220#if EV_PROTOTYPES 245#if EV_PROTOTYPES
221void ev_loop (EV_P_ int flags); 246void ev_loop (EV_P_ int flags);
222void 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 */
223 248
224ev_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 */
225 250
226/* 251/*
227 * 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
267void ev_io_start (EV_P_ struct ev_io *w); 292void ev_io_start (EV_P_ struct ev_io *w);
268void ev_io_stop (EV_P_ struct ev_io *w); 293void ev_io_stop (EV_P_ struct ev_io *w);
269 294
270void ev_timer_start (EV_P_ struct ev_timer *w); 295void ev_timer_start (EV_P_ struct ev_timer *w);
271void ev_timer_stop (EV_P_ struct ev_timer *w); 296void ev_timer_stop (EV_P_ struct ev_timer *w);
272void 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);
273 299
274void ev_periodic_start (EV_P_ struct ev_periodic *w); 300void ev_periodic_start (EV_P_ struct ev_periodic *w);
275void ev_periodic_stop (EV_P_ struct ev_periodic *w); 301void ev_periodic_stop (EV_P_ struct ev_periodic *w);
276 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 */
277void ev_signal_start (EV_P_ struct ev_signal *w); 313void ev_signal_start (EV_P_ struct ev_signal *w);
278void ev_signal_stop (EV_P_ struct ev_signal *w); 314void ev_signal_stop (EV_P_ struct ev_signal *w);
279 315
280void ev_idle_start (EV_P_ struct ev_idle *w); 316/* only supported in the default loop */
281void ev_idle_stop (EV_P_ struct ev_idle *w);
282
283void ev_prepare_start (EV_P_ struct ev_prepare *w);
284void ev_prepare_stop (EV_P_ struct ev_prepare *w);
285
286void ev_check_start (EV_P_ struct ev_check *w);
287void ev_check_stop (EV_P_ struct ev_check *w);
288
289void ev_child_start (EV_P_ struct ev_child *w); 317void ev_child_start (EV_P_ struct ev_child *w);
290void ev_child_stop (EV_P_ struct ev_child *w); 318void ev_child_stop (EV_P_ struct ev_child *w);
291#endif 319#endif
292 320
293#ifdef __cplusplus 321#ifdef __cplusplus

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines