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

Comparing libev/ev.c (file contents):
Revision 1.294 by root, Wed Jul 8 02:46:05 2009 UTC vs.
Revision 1.296 by root, Thu Jul 9 09:11:20 2009 UTC

391# define inline_speed static noinline 391# define inline_speed static noinline
392#else 392#else
393# define inline_speed static inline 393# define inline_speed static inline
394#endif 394#endif
395 395
396#define NUMPRI (EV_MAXPRI - EV_MINPRI + 1) 396#define NUMPRI (EV_MAXPRI - EV_MINPRI + 1)
397
398#if EV_MINPRI == EV_MAXPRI
399# define ABSPRI(w) (((W)w), 0)
400#else
397#define ABSPRI(w) (((W)w)->priority - EV_MINPRI) 401# define ABSPRI(w) (((W)w)->priority - EV_MINPRI)
402#endif
398 403
399#define EMPTY /* required for microsofts broken pseudo-c compiler */ 404#define EMPTY /* required for microsofts broken pseudo-c compiler */
400#define EMPTY2(a,b) /* used to suppress some warnings */ 405#define EMPTY2(a,b) /* used to suppress some warnings */
401 406
402typedef ev_watcher *W; 407typedef ev_watcher *W;
1406 1411
1407 ev_rt_now = ev_time (); 1412 ev_rt_now = ev_time ();
1408 mn_now = get_clock (); 1413 mn_now = get_clock ();
1409 now_floor = mn_now; 1414 now_floor = mn_now;
1410 rtmn_diff = ev_rt_now - mn_now; 1415 rtmn_diff = ev_rt_now - mn_now;
1416 invoke_cb = ev_invoke_pending;
1411 1417
1412 io_blocktime = 0.; 1418 io_blocktime = 0.;
1413 timeout_blocktime = 0.; 1419 timeout_blocktime = 0.;
1414 backend = 0; 1420 backend = 0;
1415 backend_fd = -1; 1421 backend_fd = -1;
1780ev_invoke (EV_P_ void *w, int revents) 1786ev_invoke (EV_P_ void *w, int revents)
1781{ 1787{
1782 EV_CB_INVOKE ((W)w, revents); 1788 EV_CB_INVOKE ((W)w, revents);
1783} 1789}
1784 1790
1785inline_speed void 1791void
1786call_pending (EV_P) 1792ev_invoke_pending (EV_P)
1787{ 1793{
1788 int pri; 1794 int pri;
1789 1795
1790 for (pri = NUMPRI; pri--; ) 1796 for (pri = NUMPRI; pri--; )
1791 while (pendingcnt [pri]) 1797 while (pendingcnt [pri])
2033{ 2039{
2034 ++loop_depth; 2040 ++loop_depth;
2035 2041
2036 loop_done = EVUNLOOP_CANCEL; 2042 loop_done = EVUNLOOP_CANCEL;
2037 2043
2038 call_pending (EV_A); /* in case we recurse, ensure ordering stays nice and clean */ 2044 invoke_cb (EV_A); /* in case we recurse, ensure ordering stays nice and clean */
2039 2045
2040 do 2046 do
2041 { 2047 {
2042#if EV_VERIFY >= 2 2048#if EV_VERIFY >= 2
2043 ev_loop_verify (EV_A); 2049 ev_loop_verify (EV_A);
2056 /* we might have forked, so queue fork handlers */ 2062 /* we might have forked, so queue fork handlers */
2057 if (expect_false (postfork)) 2063 if (expect_false (postfork))
2058 if (forkcnt) 2064 if (forkcnt)
2059 { 2065 {
2060 queue_events (EV_A_ (W *)forks, forkcnt, EV_FORK); 2066 queue_events (EV_A_ (W *)forks, forkcnt, EV_FORK);
2061 call_pending (EV_A); 2067 invoke_cb (EV_A);
2062 } 2068 }
2063#endif 2069#endif
2064 2070
2065 /* queue prepare watchers (and execute them) */ 2071 /* queue prepare watchers (and execute them) */
2066 if (expect_false (preparecnt)) 2072 if (expect_false (preparecnt))
2067 { 2073 {
2068 queue_events (EV_A_ (W *)prepares, preparecnt, EV_PREPARE); 2074 queue_events (EV_A_ (W *)prepares, preparecnt, EV_PREPARE);
2069 call_pending (EV_A); 2075 invoke_cb (EV_A);
2070 } 2076 }
2071 2077
2072 /* we might have forked, so reify kernel state if necessary */ 2078 /* we might have forked, so reify kernel state if necessary */
2073 if (expect_false (postfork)) 2079 if (expect_false (postfork))
2074 loop_fork (EV_A); 2080 loop_fork (EV_A);
2145 2151
2146 /* queue check watchers, to be executed first */ 2152 /* queue check watchers, to be executed first */
2147 if (expect_false (checkcnt)) 2153 if (expect_false (checkcnt))
2148 queue_events (EV_A_ (W *)checks, checkcnt, EV_CHECK); 2154 queue_events (EV_A_ (W *)checks, checkcnt, EV_CHECK);
2149 2155
2150 call_pending (EV_A); 2156 invoke_cb (EV_A);
2151 } 2157 }
2152 while (expect_true ( 2158 while (expect_true (
2153 activecnt 2159 activecnt
2154 && !loop_done 2160 && !loop_done
2155 && !(flags & (EVLOOP_ONESHOT | EVLOOP_NONBLOCK)) 2161 && !(flags & (EVLOOP_ONESHOT | EVLOOP_NONBLOCK))
2258} 2264}
2259 2265
2260inline_size void 2266inline_size void
2261pri_adjust (EV_P_ W w) 2267pri_adjust (EV_P_ W w)
2262{ 2268{
2263 int pri = w->priority; 2269 int pri = ev_priority (w);
2264 pri = pri < EV_MINPRI ? EV_MINPRI : pri; 2270 pri = pri < EV_MINPRI ? EV_MINPRI : pri;
2265 pri = pri > EV_MAXPRI ? EV_MAXPRI : pri; 2271 pri = pri > EV_MAXPRI ? EV_MAXPRI : pri;
2266 w->priority = pri; 2272 ev_set_priority (w, pri);
2267} 2273}
2268 2274
2269inline_speed void 2275inline_speed void
2270ev_start (EV_P_ W w, int active) 2276ev_start (EV_P_ W w, int active)
2271{ 2277{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines