… | |
… | |
29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
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> |
|
|
35 | #include <assert.h> |
34 | #include <assert.h> |
|
|
35 | |
|
|
36 | #ifndef WIN32 |
|
|
37 | # include <sys/time.h> |
|
|
38 | #endif |
36 | |
39 | |
37 | #include "ev.h" |
40 | #include "ev.h" |
38 | #include "event.h" |
41 | #include "event.h" |
39 | |
42 | |
40 | #if EV_MULTIPLICITY |
43 | #if EV_MULTIPLICITY |
… | |
… | |
238 | return 0; |
241 | return 0; |
239 | } |
242 | } |
240 | |
243 | |
241 | int event_pending (struct event *ev, short events, struct timeval *tv) |
244 | int event_pending (struct event *ev, short events, struct timeval *tv) |
242 | { |
245 | { |
|
|
246 | short revents = 0; |
243 | dLOOPev; |
247 | dLOOPev; |
244 | |
248 | |
245 | short revents = 0; |
|
|
246 | |
249 | |
247 | if (ev->ev_events & EV_SIGNAL) |
250 | if (ev->ev_events & EV_SIGNAL) |
248 | { |
251 | { |
249 | /* sig */ |
252 | /* sig */ |
250 | if (ev_is_active (&ev->iosig.sig) || ev_is_pending (&ev->iosig.sig)) |
253 | if (ev_is_active (&ev->iosig.sig) || ev_is_pending (&ev->iosig.sig)) |
… | |
… | |
309 | ev_unloop (EV_A_ EVUNLOOP_ONCE); |
312 | ev_unloop (EV_A_ EVUNLOOP_ONCE); |
310 | } |
313 | } |
311 | |
314 | |
312 | int event_base_loopexit (struct event_base *base, struct timeval *tv) |
315 | int event_base_loopexit (struct event_base *base, struct timeval *tv) |
313 | { |
316 | { |
314 | dLOOPbase; |
|
|
315 | ev_tstamp after = tv_get (tv); |
317 | ev_tstamp after = tv_get (tv); |
|
|
318 | dLOOPbase; |
316 | |
319 | |
317 | ev_once (EV_A_ -1, 0, after >= 0. ? after : 0., x_loopexit_cb, (void *)base); |
320 | ev_once (EV_A_ -1, 0, after >= 0. ? after : 0., x_loopexit_cb, (void *)base); |
318 | |
321 | |
319 | return -1; |
322 | return -1; |
320 | } |
323 | } |
… | |
… | |
335 | free (once); |
338 | free (once); |
336 | } |
339 | } |
337 | |
340 | |
338 | int event_base_once (struct event_base *base, int fd, short events, void (*cb)(int, short, void *), void *arg, struct timeval *tv) |
341 | int event_base_once (struct event_base *base, int fd, short events, void (*cb)(int, short, void *), void *arg, struct timeval *tv) |
339 | { |
342 | { |
340 | dLOOPbase; |
|
|
341 | struct x_once *once = malloc (sizeof (struct x_once)); |
343 | struct x_once *once = malloc (sizeof (struct x_once)); |
|
|
344 | dLOOPbase; |
342 | |
345 | |
343 | if (!once) |
346 | if (!once) |
344 | return -1; |
347 | return -1; |
345 | |
348 | |
346 | once->fd = fd; |
349 | once->fd = fd; |