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

Comparing libev/ev.c (file contents):
Revision 1.293 by root, Mon Jun 29 18:46:52 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;
1358ev_loop_count (EV_P) 1363ev_loop_count (EV_P)
1359{ 1364{
1360 return loop_count; 1365 return loop_count;
1361} 1366}
1362 1367
1368unsigned int
1369ev_loop_depth (EV_P)
1370{
1371 return loop_depth;
1372}
1373
1363void 1374void
1364ev_set_io_collect_interval (EV_P_ ev_tstamp interval) 1375ev_set_io_collect_interval (EV_P_ ev_tstamp interval)
1365{ 1376{
1366 io_blocktime = interval; 1377 io_blocktime = interval;
1367} 1378}
1400 1411
1401 ev_rt_now = ev_time (); 1412 ev_rt_now = ev_time ();
1402 mn_now = get_clock (); 1413 mn_now = get_clock ();
1403 now_floor = mn_now; 1414 now_floor = mn_now;
1404 rtmn_diff = ev_rt_now - mn_now; 1415 rtmn_diff = ev_rt_now - mn_now;
1416 invoke_cb = ev_invoke_pending;
1405 1417
1406 io_blocktime = 0.; 1418 io_blocktime = 0.;
1407 timeout_blocktime = 0.; 1419 timeout_blocktime = 0.;
1408 backend = 0; 1420 backend = 0;
1409 backend_fd = -1; 1421 backend_fd = -1;
1774ev_invoke (EV_P_ void *w, int revents) 1786ev_invoke (EV_P_ void *w, int revents)
1775{ 1787{
1776 EV_CB_INVOKE ((W)w, revents); 1788 EV_CB_INVOKE ((W)w, revents);
1777} 1789}
1778 1790
1779inline_speed void 1791void
1780call_pending (EV_P) 1792ev_invoke_pending (EV_P)
1781{ 1793{
1782 int pri; 1794 int pri;
1783 1795
1784 for (pri = NUMPRI; pri--; ) 1796 for (pri = NUMPRI; pri--; )
1785 while (pendingcnt [pri]) 1797 while (pendingcnt [pri])
2020 2032
2021 mn_now = ev_rt_now; 2033 mn_now = ev_rt_now;
2022 } 2034 }
2023} 2035}
2024 2036
2025static int loop_done;
2026
2027void 2037void
2028ev_loop (EV_P_ int flags) 2038ev_loop (EV_P_ int flags)
2029{ 2039{
2040 ++loop_depth;
2041
2030 loop_done = EVUNLOOP_CANCEL; 2042 loop_done = EVUNLOOP_CANCEL;
2031 2043
2032 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 */
2033 2045
2034 do 2046 do
2035 { 2047 {
2036#if EV_VERIFY >= 2 2048#if EV_VERIFY >= 2
2037 ev_loop_verify (EV_A); 2049 ev_loop_verify (EV_A);
2050 /* we might have forked, so queue fork handlers */ 2062 /* we might have forked, so queue fork handlers */
2051 if (expect_false (postfork)) 2063 if (expect_false (postfork))
2052 if (forkcnt) 2064 if (forkcnt)
2053 { 2065 {
2054 queue_events (EV_A_ (W *)forks, forkcnt, EV_FORK); 2066 queue_events (EV_A_ (W *)forks, forkcnt, EV_FORK);
2055 call_pending (EV_A); 2067 invoke_cb (EV_A);
2056 } 2068 }
2057#endif 2069#endif
2058 2070
2059 /* queue prepare watchers (and execute them) */ 2071 /* queue prepare watchers (and execute them) */
2060 if (expect_false (preparecnt)) 2072 if (expect_false (preparecnt))
2061 { 2073 {
2062 queue_events (EV_A_ (W *)prepares, preparecnt, EV_PREPARE); 2074 queue_events (EV_A_ (W *)prepares, preparecnt, EV_PREPARE);
2063 call_pending (EV_A); 2075 invoke_cb (EV_A);
2064 } 2076 }
2065 2077
2066 /* we might have forked, so reify kernel state if necessary */ 2078 /* we might have forked, so reify kernel state if necessary */
2067 if (expect_false (postfork)) 2079 if (expect_false (postfork))
2068 loop_fork (EV_A); 2080 loop_fork (EV_A);
2139 2151
2140 /* queue check watchers, to be executed first */ 2152 /* queue check watchers, to be executed first */
2141 if (expect_false (checkcnt)) 2153 if (expect_false (checkcnt))
2142 queue_events (EV_A_ (W *)checks, checkcnt, EV_CHECK); 2154 queue_events (EV_A_ (W *)checks, checkcnt, EV_CHECK);
2143 2155
2144 call_pending (EV_A); 2156 invoke_cb (EV_A);
2145 } 2157 }
2146 while (expect_true ( 2158 while (expect_true (
2147 activecnt 2159 activecnt
2148 && !loop_done 2160 && !loop_done
2149 && !(flags & (EVLOOP_ONESHOT | EVLOOP_NONBLOCK)) 2161 && !(flags & (EVLOOP_ONESHOT | EVLOOP_NONBLOCK))
2150 )); 2162 ));
2151 2163
2152 if (loop_done == EVUNLOOP_ONE) 2164 if (loop_done == EVUNLOOP_ONE)
2153 loop_done = EVUNLOOP_CANCEL; 2165 loop_done = EVUNLOOP_CANCEL;
2166
2167 --loop_depth;
2154} 2168}
2155 2169
2156void 2170void
2157ev_unloop (EV_P_ int how) 2171ev_unloop (EV_P_ int how)
2158{ 2172{
2250} 2264}
2251 2265
2252inline_size void 2266inline_size void
2253pri_adjust (EV_P_ W w) 2267pri_adjust (EV_P_ W w)
2254{ 2268{
2255 int pri = w->priority; 2269 int pri = ev_priority (w);
2256 pri = pri < EV_MINPRI ? EV_MINPRI : pri; 2270 pri = pri < EV_MINPRI ? EV_MINPRI : pri;
2257 pri = pri > EV_MAXPRI ? EV_MAXPRI : pri; 2271 pri = pri > EV_MAXPRI ? EV_MAXPRI : pri;
2258 w->priority = pri; 2272 ev_set_priority (w, pri);
2259} 2273}
2260 2274
2261inline_speed void 2275inline_speed void
2262ev_start (EV_P_ W w, int active) 2276ev_start (EV_P_ W w, int active)
2263{ 2277{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines