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

Comparing libev/event.c (file contents):
Revision 1.42 by root, Mon May 10 20:01:45 2010 UTC vs.
Revision 1.45 by root, Thu Oct 21 12:32:48 2010 UTC

1/* 1/*
2 * libevent compatibility layer 2 * libevent compatibility layer
3 * 3 *
4 * Copyright (c) 2007,2008,2009 Marc Alexander Lehmann <libev@schmorp.de> 4 * Copyright (c) 2007,2008,2009,2010 Marc Alexander Lehmann <libev@schmorp.de>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without modifica- 7 * Redistribution and use in source and binary forms, with or without modifica-
8 * tion, are permitted provided that the following conditions are met: 8 * tion, are permitted provided that the following conditions are met:
9 * 9 *
61 int dummy; 61 int dummy;
62}; 62};
63 63
64static struct event_base *ev_x_cur; 64static struct event_base *ev_x_cur;
65 65
66static void
67ev_tv_set (struct timeval *tv, ev_tstamp at)
68{
69 tv->tv_sec = (long)at;
70 tv->tv_usec = (long)((at - (ev_tstamp)tv->tv_sec) * 1e6);
71}
72
73static ev_tstamp 66static ev_tstamp
74ev_tv_get (struct timeval *tv) 67ev_tv_get (struct timeval *tv)
75{ 68{
76 if (tv) 69 if (tv)
77 { 70 {
145} 138}
146 139
147static void 140static void
148ev_x_cb (struct event *ev, int revents) 141ev_x_cb (struct event *ev, int revents)
149{ 142{
150 revents &= EV_READ | EV_WRITE | EV_TIMEOUT | EV_SIGNAL; 143 revents &= EV_READ | EV_WRITE | EV_TIMER | EV_SIGNAL;
151 144
152 ev->ev_res = revents; 145 ev->ev_res = revents;
153 ev->ev_callback (ev->ev_fd, (short)revents, ev->ev_arg); 146 ev->ev_callback (ev->ev_fd, (short)revents, ev->ev_arg);
154} 147}
155 148
303 if (ev->ev_events & EV_TIMEOUT || ev_is_active (&ev->to) || ev_is_pending (&ev->to)) 296 if (ev->ev_events & EV_TIMEOUT || ev_is_active (&ev->to) || ev_is_pending (&ev->to))
304 { 297 {
305 revents |= EV_TIMEOUT; 298 revents |= EV_TIMEOUT;
306 299
307 if (tv) 300 if (tv)
308 ev_tv_set (tv, ev_now (EV_A)); /* not sure if this is right :) */ 301 EV_TV_SET (tv, ev_now (EV_A)); /* not sure if this is right :) */
309 } 302 }
310 303
311 return events & revents; 304 return events & revents;
312} 305}
313 306
332 325
333int event_base_loop (struct event_base *base, int flags) 326int event_base_loop (struct event_base *base, int flags)
334{ 327{
335 dLOOPbase; 328 dLOOPbase;
336 329
337 ev_loop (EV_A_ flags); 330 ev_run (EV_A_ flags);
338 331
339 return 0; 332 return 0;
340} 333}
341 334
342int event_base_dispatch (struct event_base *base) 335int event_base_dispatch (struct event_base *base)
347static void 340static void
348ev_x_loopexit_cb (int revents, void *base) 341ev_x_loopexit_cb (int revents, void *base)
349{ 342{
350 dLOOPbase; 343 dLOOPbase;
351 344
352 ev_unloop (EV_A_ EVUNLOOP_ONE); 345 ev_break (EV_A_ EVBREAK_ONE);
353} 346}
354 347
355int event_base_loopexit (struct event_base *base, struct timeval *tv) 348int event_base_loopexit (struct event_base *base, struct timeval *tv)
356{ 349{
357 ev_tstamp after = ev_tv_get (tv); 350 ev_tstamp after = ev_tv_get (tv);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines