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

Comparing libev/ev.c (file contents):
Revision 1.29 by root, Thu Nov 1 08:10:03 2007 UTC vs.
Revision 1.30 by root, Thu Nov 1 08:28:33 2007 UTC

113#endif 113#endif
114 114
115 return ev_time (); 115 return ev_time ();
116} 116}
117 117
118#define array_nextsize(n) (((n) << 1) | 4 & ~3) 118#define array_roundsize(base,n) ((n) | 4 & ~3)
119#define array_prevsize(n) (((n) >> 1) | 4 & ~3)
120 119
121#define array_needsize(base,cur,cnt,init) \ 120#define array_needsize(base,cur,cnt,init) \
122 if ((cnt) > cur) \ 121 if ((cnt) > cur) \
123 { \ 122 { \
124 int newcnt = cur; \ 123 int newcnt = cur; \
125 do \ 124 do \
126 { \ 125 { \
127 newcnt = array_nextsize (newcnt); \ 126 newcnt = array_roundsize (base, newcnt << 1); \
128 } \ 127 } \
129 while ((cnt) > newcnt); \ 128 while ((cnt) > newcnt); \
130 \ 129 \
131 base = realloc (base, sizeof (*base) * (newcnt)); \ 130 base = realloc (base, sizeof (*base) * (newcnt)); \
132 init (base + cur, newcnt - cur); \ 131 init (base + cur, newcnt - cur); \
165static int pendingmax, pendingcnt; 164static int pendingmax, pendingcnt;
166 165
167static void 166static void
168event (W w, int events) 167event (W w, int events)
169{ 168{
170 if (w->active)
171 {
172 w->pending = ++pendingcnt; 169 w->pending = ++pendingcnt;
173 array_needsize (pendings, pendingmax, pendingcnt, ); 170 array_needsize (pendings, pendingmax, pendingcnt, );
174 pendings [pendingcnt - 1].w = w; 171 pendings [pendingcnt - 1].w = w;
175 pendings [pendingcnt - 1].events = events; 172 pendings [pendingcnt - 1].events = events;
176 }
177} 173}
178 174
179static void 175static void
180queue_events (W *events, int eventcnt, int type) 176queue_events (W *events, int eventcnt, int type)
181{ 177{
529{ 525{
530 while (timercnt && timers [0]->at <= now) 526 while (timercnt && timers [0]->at <= now)
531 { 527 {
532 struct ev_timer *w = timers [0]; 528 struct ev_timer *w = timers [0];
533 529
534 event ((W)w, EV_TIMEOUT);
535
536 /* first reschedule or stop timer */ 530 /* first reschedule or stop timer */
537 if (w->repeat) 531 if (w->repeat)
538 { 532 {
539 w->at = now + w->repeat; 533 w->at = now + w->repeat;
540 assert (("timer timeout in the past, negative repeat?", w->at > now)); 534 assert (("timer timeout in the past, negative repeat?", w->at > now));
541 downheap ((WT *)timers, timercnt, 0); 535 downheap ((WT *)timers, timercnt, 0);
542 } 536 }
543 else 537 else
544 ev_timer_stop (w); /* nonrepeating: stop timer */ 538 ev_timer_stop (w); /* nonrepeating: stop timer */
539
540 event ((W)w, EV_TIMEOUT);
545 } 541 }
546} 542}
547 543
548static void 544static void
549periodics_reify (void) 545periodics_reify (void)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines