… | |
… | |
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 | |
402 | typedef ev_watcher *W; |
407 | typedef 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; |
… | |
… | |
1780 | ev_invoke (EV_P_ void *w, int revents) |
1786 | ev_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 | |
1785 | inline_speed void |
1791 | void |
1786 | call_pending (EV_P) |
1792 | ev_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 | |
2260 | inline_size void |
2266 | inline_size void |
2261 | pri_adjust (EV_P_ W w) |
2267 | pri_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 | |
2269 | inline_speed void |
2275 | inline_speed void |
2270 | ev_start (EV_P_ W w, int active) |
2276 | ev_start (EV_P_ W w, int active) |
2271 | { |
2277 | { |