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

Comparing libev/ev.c (file contents):
Revision 1.41 by root, Fri Nov 2 16:54:34 2007 UTC vs.
Revision 1.42 by root, Fri Nov 2 20:05:05 2007 UTC

100#endif 100#endif
101 101
102#define expect_false(expr) expect ((expr) != 0, 0) 102#define expect_false(expr) expect ((expr) != 0, 0)
103#define expect_true(expr) expect ((expr) != 0, 1) 103#define expect_true(expr) expect ((expr) != 0, 1)
104 104
105#define NUMPRI (EV_MAXPRI - EV_MINPRI + 1)
106#define ABSPRI(w) ((w)->priority - EV_MINPRI)
107
105typedef struct ev_watcher *W; 108typedef struct ev_watcher *W;
106typedef struct ev_watcher_list *WL; 109typedef struct ev_watcher_list *WL;
107typedef struct ev_watcher_time *WT; 110typedef struct ev_watcher_time *WT;
108 111
109static ev_tstamp now_floor, now, diff; /* monotonic clock */ 112static ev_tstamp now_floor, now, diff; /* monotonic clock */
193{ 196{
194 W w; 197 W w;
195 int events; 198 int events;
196} ANPENDING; 199} ANPENDING;
197 200
198static ANPENDING *pendings; 201static ANPENDING *pendings [NUMPRI];
199static int pendingmax, pendingcnt; 202static int pendingmax [NUMPRI], pendingcnt [NUMPRI];
200 203
201static void 204static void
202event (W w, int events) 205event (W w, int events)
203{ 206{
204 if (w->pending) 207 if (w->pending)
205 { 208 {
206 pendings [w->pending - 1].events |= events; 209 pendings [ABSPRI (w)][w->pending - 1].events |= events;
207 return; 210 return;
208 } 211 }
209 212
210 w->pending = ++pendingcnt; 213 w->pending = ++pendingcnt [ABSPRI (w)];
211 array_needsize (pendings, pendingmax, pendingcnt, ); 214 array_needsize (pendings [ABSPRI (w)], pendingmax [ABSPRI (w)], pendingcnt [ABSPRI (w)], );
212 pendings [pendingcnt - 1].w = w; 215 pendings [ABSPRI (w)][w->pending - 1].w = w;
213 pendings [pendingcnt - 1].events = events; 216 pendings [ABSPRI (w)][w->pending - 1].events = events;
214} 217}
215 218
216static void 219static void
217queue_events (W *events, int eventcnt, int type) 220queue_events (W *events, int eventcnt, int type)
218{ 221{
593/*****************************************************************************/ 596/*****************************************************************************/
594 597
595static void 598static void
596call_pending (void) 599call_pending (void)
597{ 600{
601 int pri;
602
603 for (pri = NUMPRI; pri--; )
598 while (pendingcnt) 604 while (pendingcnt [pri])
599 { 605 {
600 ANPENDING *p = pendings + --pendingcnt; 606 ANPENDING *p = pendings [pri] + --pendingcnt [pri];
601 607
602 if (p->w) 608 if (p->w)
603 { 609 {
604 p->w->pending = 0; 610 p->w->pending = 0;
605 p->w->cb (p->w, p->events); 611 p->w->cb (p->w, p->events);
606 } 612 }
607 } 613 }
608} 614}
609 615
610static void 616static void
611timers_reify (void) 617timers_reify (void)
612{ 618{
844static void 850static void
845ev_clear_pending (W w) 851ev_clear_pending (W w)
846{ 852{
847 if (w->pending) 853 if (w->pending)
848 { 854 {
849 pendings [w->pending - 1].w = 0; 855 pendings [ABSPRI (w)][w->pending - 1].w = 0;
850 w->pending = 0; 856 w->pending = 0;
851 } 857 }
852} 858}
853 859
854static void 860static void

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines