… | |
… | |
870 | select (0, 0, 0, 0, &tv); |
870 | select (0, 0, 0, 0, &tv); |
871 | #endif |
871 | #endif |
872 | } |
872 | } |
873 | } |
873 | } |
874 | |
874 | |
875 | inline_speed int |
|
|
876 | ev_timeout_to_ms (ev_tstamp timeout) |
|
|
877 | { |
|
|
878 | int ms = timeout * 1000. + .999999; |
|
|
879 | |
|
|
880 | return expect_true (ms) ? ms : timeout < 1e-6 ? 0 : 1; |
|
|
881 | } |
|
|
882 | |
|
|
883 | /*****************************************************************************/ |
875 | /*****************************************************************************/ |
884 | |
876 | |
885 | #define MALLOC_ROUND 4096 /* prefer to allocate in chunks of this size, must be 2**n and >> 4 longs */ |
877 | #define MALLOC_ROUND 4096 /* prefer to allocate in chunks of this size, must be 2**n and >> 4 longs */ |
886 | |
878 | |
887 | /* find a suitable new size for the given array, */ |
879 | /* find a suitable new size for the given array, */ |
… | |
… | |
2513 | { |
2505 | { |
2514 | waittime = MAX_BLOCKTIME; |
2506 | waittime = MAX_BLOCKTIME; |
2515 | |
2507 | |
2516 | if (timercnt) |
2508 | if (timercnt) |
2517 | { |
2509 | { |
2518 | ev_tstamp to = ANHE_at (timers [HEAP0]) - mn_now + backend_fudge; |
2510 | ev_tstamp to = ANHE_at (timers [HEAP0]) - mn_now + backend_mintime; |
2519 | if (waittime > to) waittime = to; |
2511 | if (waittime > to) waittime = to; |
2520 | } |
2512 | } |
2521 | |
2513 | |
2522 | #if EV_PERIODIC_ENABLE |
2514 | #if EV_PERIODIC_ENABLE |
2523 | if (periodiccnt) |
2515 | if (periodiccnt) |
2524 | { |
2516 | { |
2525 | ev_tstamp to = ANHE_at (periodics [HEAP0]) - ev_rt_now + backend_fudge; |
2517 | ev_tstamp to = ANHE_at (periodics [HEAP0]) - ev_rt_now + backend_mintime; |
2526 | if (waittime > to) waittime = to; |
2518 | if (waittime > to) waittime = to; |
2527 | } |
2519 | } |
2528 | #endif |
2520 | #endif |
2529 | |
2521 | |
2530 | /* don't let timeouts decrease the waittime below timeout_blocktime */ |
2522 | /* don't let timeouts decrease the waittime below timeout_blocktime */ |
… | |
… | |
2534 | /* extra check because io_blocktime is commonly 0 */ |
2526 | /* extra check because io_blocktime is commonly 0 */ |
2535 | if (expect_false (io_blocktime)) |
2527 | if (expect_false (io_blocktime)) |
2536 | { |
2528 | { |
2537 | sleeptime = io_blocktime - (mn_now - prev_mn_now); |
2529 | sleeptime = io_blocktime - (mn_now - prev_mn_now); |
2538 | |
2530 | |
2539 | if (sleeptime > waittime - backend_fudge) |
2531 | if (sleeptime > waittime - backend_mintime) |
2540 | sleeptime = waittime - backend_fudge; |
2532 | sleeptime = waittime - backend_mintime; |
2541 | |
2533 | |
2542 | if (expect_true (sleeptime > 0.)) |
2534 | if (expect_true (sleeptime > 0.)) |
2543 | { |
2535 | { |
2544 | ev_sleep (sleeptime); |
2536 | ev_sleep (sleeptime); |
2545 | waittime -= sleeptime; |
2537 | waittime -= sleeptime; |