… | |
… | |
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 | #include <assert.h> |
36 | |
36 | |
37 | #ifndef EV_EMBED |
37 | #include "ev.h" |
38 | # include "event.h" |
38 | #include "event.h" |
39 | #endif |
|
|
40 | |
39 | |
41 | #if EV_MULTIPLICITY |
40 | #if EV_MULTIPLICITY |
42 | # 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 |
43 | # define dLOOPbase struct ev_loop *loop = (struct ev_loop *)base |
42 | # define dLOOPbase struct ev_loop *loop = (struct ev_loop *)base |
44 | #else |
43 | #else |
… | |
… | |
86 | { |
85 | { |
87 | #if EV_MULTIPLICITY |
86 | #if EV_MULTIPLICITY |
88 | if (x_cur) |
87 | if (x_cur) |
89 | x_cur = (struct event_base *)ev_loop_new (EVMETHOD_AUTO); |
88 | x_cur = (struct event_base *)ev_loop_new (EVMETHOD_AUTO); |
90 | else |
89 | else |
91 | x_cur = ev_default_loop (EVMETHOD_AUTO); |
90 | x_cur = (struct event_base *)ev_default_loop (EVMETHOD_AUTO); |
92 | #else |
91 | #else |
93 | assert (("multiple event bases not supported when not compiled with EV_MULTIPLICITY", !x_cur)); |
92 | assert (("multiple event bases not supported when not compiled with EV_MULTIPLICITY", !x_cur)); |
94 | |
93 | |
95 | x_cur = (struct event_base *)ev_default_loop (EVMETHOD_AUTO); |
94 | x_cur = (struct event_base *)ev_default_loop (EVMETHOD_AUTO); |
96 | #endif |
95 | #endif |
… | |
… | |
101 | void event_base_free (struct event_base *base) |
100 | void event_base_free (struct event_base *base) |
102 | { |
101 | { |
103 | dLOOPbase; |
102 | dLOOPbase; |
104 | |
103 | |
105 | #if EV_MULTIPLICITY |
104 | #if EV_MULTIPLICITY |
|
|
105 | if (ev_default_loop (EVMETHOD_AUTO) != loop) |
106 | ev_loop_delete (loop); |
106 | ev_loop_destroy (loop); |
107 | #endif |
107 | #endif |
108 | } |
108 | } |
109 | |
109 | |
110 | int event_dispatch (void) |
110 | int event_dispatch (void) |
111 | { |
111 | { |
112 | return event_base_dispatch (x_cur); |
112 | return event_base_dispatch (x_cur); |
113 | } |
113 | } |
114 | |
114 | |
115 | #ifdef EV_EMBED |
115 | #ifdef EV_STANDALONE |
116 | void event_set_log_callback (event_log_cb cb) |
116 | void event_set_log_callback (event_log_cb cb) |
117 | { |
117 | { |
118 | /* nop */ |
118 | /* nop */ |
119 | } |
119 | } |
120 | #endif |
120 | #endif |
… | |
… | |
353 | return 0; |
353 | return 0; |
354 | } |
354 | } |
355 | |
355 | |
356 | int event_base_priority_init (struct event_base *base, int npri) |
356 | int event_base_priority_init (struct event_base *base, int npri) |
357 | { |
357 | { |
358 | dLOOPbase; |
358 | /*dLOOPbase;*/ |
359 | |
359 | |
360 | return 0; |
360 | return 0; |
361 | } |
361 | } |
362 | |
362 | |