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

Comparing libev/ev.c (file contents):
Revision 1.97 by root, Sun Nov 11 01:53:07 2007 UTC vs.
Revision 1.99 by root, Sun Nov 11 02:26:47 2007 UTC

161typedef struct ev_watcher_list *WL; 161typedef struct ev_watcher_list *WL;
162typedef struct ev_watcher_time *WT; 162typedef struct ev_watcher_time *WT;
163 163
164static int have_monotonic; /* did clock_gettime (CLOCK_MONOTONIC) work? */ 164static int have_monotonic; /* did clock_gettime (CLOCK_MONOTONIC) work? */
165 165
166#ifdef WIN32
166#include "ev_win32.c" 167# include "ev_win32.c"
168#endif
167 169
168/*****************************************************************************/ 170/*****************************************************************************/
169 171
170static void (*syserr_cb)(const char *msg); 172static void (*syserr_cb)(const char *msg);
171 173
231#if EV_MULTIPLICITY 233#if EV_MULTIPLICITY
232 234
233 struct ev_loop 235 struct ev_loop
234 { 236 {
235 ev_tstamp ev_rt_now; 237 ev_tstamp ev_rt_now;
238 #define ev_rt_now ((loop)->ev_rt_now)
236 #define VAR(name,decl) decl; 239 #define VAR(name,decl) decl;
237 #include "ev_vars.h" 240 #include "ev_vars.h"
238 #undef VAR 241 #undef VAR
239 }; 242 };
240 #include "ev_wrap.h" 243 #include "ev_wrap.h"
532 heap [k] = w; 535 heap [k] = w;
533 ((W)heap [k])->active = k + 1; 536 ((W)heap [k])->active = k + 1;
534} 537}
535 538
536inline void 539inline void
537adjustheap (WT *heap, int N, int k, ev_tstamp at) 540adjustheap (WT *heap, int N, int k)
538{ 541{
539 ev_tstamp old_at = heap [k]->at; 542 upheap (heap, k);
540 heap [k]->at = at;
541
542 if (old_at < at)
543 downheap (heap, N, k); 543 downheap (heap, N, k);
544 else
545 upheap (heap, k);
546} 544}
547 545
548/*****************************************************************************/ 546/*****************************************************************************/
549 547
550typedef struct 548typedef struct
1350 assert (("internal timer heap corruption", timers [((W)w)->active - 1] == w)); 1348 assert (("internal timer heap corruption", timers [((W)w)->active - 1] == w));
1351 1349
1352 if (((W)w)->active < timercnt--) 1350 if (((W)w)->active < timercnt--)
1353 { 1351 {
1354 timers [((W)w)->active - 1] = timers [timercnt]; 1352 timers [((W)w)->active - 1] = timers [timercnt];
1355 downheap ((WT *)timers, timercnt, ((W)w)->active - 1); 1353 adjustheap ((WT *)timers, timercnt, ((W)w)->active - 1);
1356 } 1354 }
1357 1355
1358 ((WT)w)->at -= mn_now; 1356 ((WT)w)->at -= mn_now;
1359 1357
1360 ev_stop (EV_A_ (W)w); 1358 ev_stop (EV_A_ (W)w);
1364ev_timer_again (EV_P_ struct ev_timer *w) 1362ev_timer_again (EV_P_ struct ev_timer *w)
1365{ 1363{
1366 if (ev_is_active (w)) 1364 if (ev_is_active (w))
1367 { 1365 {
1368 if (w->repeat) 1366 if (w->repeat)
1367 {
1368 ((WT)w)->at = mn_now + w->repeat;
1369 adjustheap ((WT *)timers, timercnt, ((W)w)->active - 1, mn_now + w->repeat); 1369 adjustheap ((WT *)timers, timercnt, ((W)w)->active - 1);
1370 }
1370 else 1371 else
1371 ev_timer_stop (EV_A_ w); 1372 ev_timer_stop (EV_A_ w);
1372 } 1373 }
1373 else if (w->repeat) 1374 else if (w->repeat)
1374 ev_timer_start (EV_A_ w); 1375 ev_timer_start (EV_A_ w);
1408 assert (("internal periodic heap corruption", periodics [((W)w)->active - 1] == w)); 1409 assert (("internal periodic heap corruption", periodics [((W)w)->active - 1] == w));
1409 1410
1410 if (((W)w)->active < periodiccnt--) 1411 if (((W)w)->active < periodiccnt--)
1411 { 1412 {
1412 periodics [((W)w)->active - 1] = periodics [periodiccnt]; 1413 periodics [((W)w)->active - 1] = periodics [periodiccnt];
1413 downheap ((WT *)periodics, periodiccnt, ((W)w)->active - 1); 1414 adjustheap ((WT *)periodics, periodiccnt, ((W)w)->active - 1);
1414 } 1415 }
1415 1416
1416 ev_stop (EV_A_ (W)w); 1417 ev_stop (EV_A_ (W)w);
1417} 1418}
1418 1419

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines