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

Comparing libev/ev.c (file contents):
Revision 1.279 by root, Fri Feb 6 20:17:43 2009 UTC vs.
Revision 1.283 by root, Wed Apr 15 09:51:19 2009 UTC

676 fprintf (stderr, "slimmed down " # stem " to %d\n", stem ## max);/*D*/\ 676 fprintf (stderr, "slimmed down " # stem " to %d\n", stem ## max);/*D*/\
677 } 677 }
678#endif 678#endif
679 679
680#define array_free(stem, idx) \ 680#define array_free(stem, idx) \
681 ev_free (stem ## s idx); stem ## cnt idx = stem ## max idx = 0; 681 ev_free (stem ## s idx); stem ## cnt idx = stem ## max idx = 0; stem ## s idx = 0
682 682
683/*****************************************************************************/ 683/*****************************************************************************/
684 684
685void noinline 685void noinline
686ev_feed_event (EV_P_ void *w, int revents) 686ev_feed_event (EV_P_ void *w, int revents)
766 unsigned char o_reify = anfd->reify; 766 unsigned char o_reify = anfd->reify;
767 767
768 anfd->reify = 0; 768 anfd->reify = 0;
769 anfd->events = events; 769 anfd->events = events;
770 770
771 if (o_events != events || o_reify & EV_IOFDSET) 771 if (o_events != events || o_reify & EV__IOFDSET)
772 backend_modify (EV_A_ fd, o_events, events); 772 backend_modify (EV_A_ fd, o_events, events);
773 } 773 }
774 } 774 }
775 775
776 fdchangecnt = 0; 776 fdchangecnt = 0;
847 for (fd = 0; fd < anfdmax; ++fd) 847 for (fd = 0; fd < anfdmax; ++fd)
848 if (anfds [fd].events) 848 if (anfds [fd].events)
849 { 849 {
850 anfds [fd].events = 0; 850 anfds [fd].events = 0;
851 anfds [fd].emask = 0; 851 anfds [fd].emask = 0;
852 fd_change (EV_A_ fd, EV_IOFDSET | 1); 852 fd_change (EV_A_ fd, EV__IOFDSET | 1);
853 } 853 }
854} 854}
855 855
856/*****************************************************************************/ 856/*****************************************************************************/
857 857
1997 { 1997 {
1998 queue_events (EV_A_ (W *)prepares, preparecnt, EV_PREPARE); 1998 queue_events (EV_A_ (W *)prepares, preparecnt, EV_PREPARE);
1999 call_pending (EV_A); 1999 call_pending (EV_A);
2000 } 2000 }
2001 2001
2002 if (expect_false (!activecnt))
2003 break;
2004
2005 /* we might have forked, so reify kernel state if necessary */ 2002 /* we might have forked, so reify kernel state if necessary */
2006 if (expect_false (postfork)) 2003 if (expect_false (postfork))
2007 loop_fork (EV_A); 2004 loop_fork (EV_A);
2008 2005
2009 /* update fd-related kernel structures */ 2006 /* update fd-related kernel structures */
2174 2171
2175 if (expect_false (ev_is_active (w))) 2172 if (expect_false (ev_is_active (w)))
2176 return; 2173 return;
2177 2174
2178 assert (("libev: ev_io_start called with negative fd", fd >= 0)); 2175 assert (("libev: ev_io_start called with negative fd", fd >= 0));
2179 assert (("libev: ev_io start called with illegal event mask", !(w->events & ~(EV_IOFDSET | EV_READ | EV_WRITE)))); 2176 assert (("libev: ev_io start called with illegal event mask", !(w->events & ~(EV__IOFDSET | EV_READ | EV_WRITE))));
2180 2177
2181 EV_FREQUENT_CHECK; 2178 EV_FREQUENT_CHECK;
2182 2179
2183 ev_start (EV_A_ (W)w, 1); 2180 ev_start (EV_A_ (W)w, 1);
2184 array_needsize (ANFD, anfds, anfdmax, fd + 1, array_init_zero); 2181 array_needsize (ANFD, anfds, anfdmax, fd + 1, array_init_zero);
2185 wlist_add (&anfds[fd].head, (WL)w); 2182 wlist_add (&anfds[fd].head, (WL)w);
2186 2183
2187 fd_change (EV_A_ fd, w->events & EV_IOFDSET | 1); 2184 fd_change (EV_A_ fd, w->events & EV__IOFDSET | 1);
2188 w->events &= ~EV_IOFDSET; 2185 w->events &= ~EV__IOFDSET;
2189 2186
2190 EV_FREQUENT_CHECK; 2187 EV_FREQUENT_CHECK;
2191} 2188}
2192 2189
2193void noinline 2190void noinline
3146 ev_timer_set (&once->to, timeout, 0.); 3143 ev_timer_set (&once->to, timeout, 0.);
3147 ev_timer_start (EV_A_ &once->to); 3144 ev_timer_start (EV_A_ &once->to);
3148 } 3145 }
3149} 3146}
3150 3147
3148/*****************************************************************************/
3149
3150#if 0
3151void
3152ev_walk (EV_P_ int types, void (*cb)(EV_P_ int type, void *w))
3153{
3154 int i, j;
3155 ev_watcher_list *wl, *wn;
3156
3157 if (types & (EV_IO | EV_EMBED))
3158 for (i = 0; i < anfdmax; ++i)
3159 for (wl = anfds [i].head; wl; )
3160 {
3161 wn = wl->next;
3162
3163#if EV_EMBED_ENABLE
3164 if (ev_cb ((ev_io *)wl) == embed_io_cb)
3165 {
3166 if (types & EV_EMBED)
3167 cb (EV_A_ EV_EMBED, ((char *)wl) - offsetof (struct ev_embed, io));
3168 }
3169 else
3170#endif
3171#if EV_USE_INOTIFY
3172 if (ev_cb ((ev_io *)wl) == infy_cb)
3173 ;
3174 else
3175#endif
3176 if ((ev_io *)wl != &pipeev)
3177 if (types & EV_IO)
3178 cb (EV_A_ EV_IO, wl);
3179
3180 wl = wn;
3181 }
3182
3183 if (types & (EV_TIMER | EV_STAT))
3184 for (i = timercnt + HEAP0; i-- > HEAP0; )
3185#if EV_STAT_ENABLE
3186 /*TODO: timer is not always active*/
3187 if (ev_cb ((ev_timer *)ANHE_w (timers [i])) == stat_timer_cb)
3188 {
3189 if (types & EV_STAT)
3190 cb (EV_A_ EV_STAT, ((char *)ANHE_w (timers [i])) - offsetof (struct ev_stat, timer));
3191 }
3192 else
3193#endif
3194 if (types & EV_TIMER)
3195 cb (EV_A_ EV_TIMER, ANHE_w (timers [i]));
3196
3197#if EV_PERIODIC_ENABLE
3198 if (types & EV_PERIODIC)
3199 for (i = periodiccnt + HEAP0; i-- > HEAP0; )
3200 cb (EV_A_ EV_PERIODIC, ANHE_w (periodics [i]));
3201#endif
3202
3203#if EV_IDLE_ENABLE
3204 if (types & EV_IDLE)
3205 for (j = NUMPRI; i--; )
3206 for (i = idlecnt [j]; i--; )
3207 cb (EV_A_ EV_IDLE, idles [j][i]);
3208#endif
3209
3210#if EV_FORK_ENABLE
3211 if (types & EV_FORK)
3212 for (i = forkcnt; i--; )
3213 if (ev_cb (forks [i]) != embed_fork_cb)
3214 cb (EV_A_ EV_FORK, forks [i]);
3215#endif
3216
3217#if EV_ASYNC_ENABLE
3218 if (types & EV_ASYNC)
3219 for (i = asynccnt; i--; )
3220 cb (EV_A_ EV_ASYNC, asyncs [i]);
3221#endif
3222
3223 if (types & EV_PREPARE)
3224 for (i = preparecnt; i--; )
3225#if EV_EMBED_ENABLE
3226 if (ev_cb (prepares [i]) != embed_prepare_cb)
3227#endif
3228 cb (EV_A_ EV_PREPARE, prepares [i]);
3229
3230 if (types & EV_CHECK)
3231 for (i = checkcnt; i--; )
3232 cb (EV_A_ EV_CHECK, checks [i]);
3233
3234 if (types & EV_SIGNAL)
3235 for (i = 0; i < signalmax; ++i)
3236 for (wl = signals [i].head; wl; )
3237 {
3238 wn = wl->next;
3239 cb (EV_A_ EV_SIGNAL, wl);
3240 wl = wn;
3241 }
3242
3243 if (types & EV_CHILD)
3244 for (i = EV_PID_HASHSIZE; i--; )
3245 for (wl = childs [i]; wl; )
3246 {
3247 wn = wl->next;
3248 cb (EV_A_ EV_CHILD, wl);
3249 wl = wn;
3250 }
3251/* EV_STAT 0x00001000 /* stat data changed */
3252/* EV_EMBED 0x00010000 /* embedded event loop needs sweep */
3253}
3254#endif
3255
3151#if EV_MULTIPLICITY 3256#if EV_MULTIPLICITY
3152 #include "ev_wrap.h" 3257 #include "ev_wrap.h"
3153#endif 3258#endif
3154 3259
3155#ifdef __cplusplus 3260#ifdef __cplusplus

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines