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

Comparing libev/event.c (file contents):
Revision 1.9 by root, Sun Nov 4 00:24:17 2007 UTC vs.
Revision 1.13 by root, Sun Nov 4 18:29:44 2007 UTC

30 */ 30 */
31 31
32#include <stddef.h> 32#include <stddef.h>
33#include <stdlib.h> 33#include <stdlib.h>
34#include <sys/time.h> 34#include <sys/time.h>
35#include <assert.h>
35 36
37#include "ev.h"
36#include "event.h" 38#include "event.h"
37 39
38#if EV_MULTIPLICITY 40#if EV_MULTIPLICITY
39# define dLOOPev struct ev_loop *loop = (struct ev_loop *)ev->ev_base 41# define dLOOPev struct ev_loop *loop = (struct ev_loop *)ev->ev_base
40# define dLOOPbase struct ev_loop *loop = (struct ev_loop *)base 42# define dLOOPbase struct ev_loop *loop = (struct ev_loop *)base
47struct event_base 49struct event_base
48{ 50{
49 int dummy; 51 int dummy;
50}; 52};
51 53
52static struct event_base x_base, *x_cur; 54static struct event_base *x_cur;
53 55
54static void 56static void
55tv_set (struct timeval *tv, ev_tstamp at) 57tv_set (struct timeval *tv, ev_tstamp at)
56{ 58{
57 tv->tv_sec = (long)at; 59 tv->tv_sec = (long)at;
80} 82}
81 83
82void *event_init (void) 84void *event_init (void)
83{ 85{
84#if EV_MULTIPLICITY 86#if EV_MULTIPLICITY
87 if (x_cur)
85 x_cur = (struct event_base *)ev_loop_new (EVMETHOD_AUTO); 88 x_cur = (struct event_base *)ev_loop_new (EVMETHOD_AUTO);
89 else
90 x_cur = (struct event_base *)ev_default_loop (EVMETHOD_AUTO);
86#else 91#else
87 x_cur = &x_base; 92 assert (("multiple event bases not supported when not compiled with EV_MULTIPLICITY", !x_cur));
93
94 x_cur = (struct event_base *)ev_default_loop (EVMETHOD_AUTO);
88#endif 95#endif
89 96
90 return x_cur; 97 return x_cur;
91} 98}
92 99
93void event_base_free (struct event_base *base) 100void event_base_free (struct event_base *base)
94{ 101{
95 dLOOPbase; 102 dLOOPbase;
96 103
97#if EV_MULTIPLICITY 104#if EV_MULTIPLICITY
105 if (ev_default_loop (EVMETHOD_AUTO) != loop)
98 ev_loop_delete (loop); 106 ev_loop_destroy (loop);
99#endif 107#endif
100} 108}
101 109
102int event_dispatch (void) 110int event_dispatch (void)
103{ 111{
345 return 0; 353 return 0;
346} 354}
347 355
348int event_base_priority_init (struct event_base *base, int npri) 356int event_base_priority_init (struct event_base *base, int npri)
349{ 357{
350 dLOOPbase; 358 /*dLOOPbase;*/
351 359
352 return 0; 360 return 0;
353} 361}
354 362

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines