diff options
-rw-r--r-- | Changes | 7 | ||||
-rw-r--r-- | ev.c | 8 | ||||
-rw-r--r-- | ev.pod | 12 | ||||
-rw-r--r-- | ev_epoll.c | 6 | ||||
-rw-r--r-- | ev_poll.c | 2 |
5 files changed, 19 insertions, 16 deletions
@@ -5,14 +5,17 @@ TODO: ev_loop_wakeup TODO: confusion about threads ongiong TODO: not_blocked flag. +TODO: ev_sleep suffers from different backend_fudge... - correct backend_fudge for most backends, and implement a windows specific workaround to avoid looping because we call both select and Sleep, both with different time resolutions. + - document range and guarantees of ev_sleep. - change the default periodic reschedule function to hopefully be more exact and correct even in corner cases or in the far future. - - document reasonable ranges for interval and offset. + - document reasonable ranges for periodics interval and offset. - do not rely on -lm anymore: use it when available but use our - own floor () if it is missing. This should make it easier to embed. + own floor () if it is missing. This should make it easier to embed, + as no external libraries are required. 4.04 Wed Feb 16 09:01:51 CET 2011 - fix two problems in the native win32 backend, where reuse of fd's @@ -872,14 +872,6 @@ ev_sleep (ev_tstamp delay) } } -inline_speed int -ev_timeout_to_ms (ev_tstamp timeout) -{ - int ms = timeout * 1000. + .999999; - - return expect_true (ms) ? ms : timeout < 1e-6 ? 0 : 1; -} - /*****************************************************************************/ #define MALLOC_ROUND 4096 /* prefer to allocate in chunks of this size, must be 2**n and >> 4 longs */ @@ -180,9 +180,15 @@ C<ev_update_now> and C<ev_now>. =item ev_sleep (ev_tstamp interval) -Sleep for the given interval: The current thread will be blocked until -either it is interrupted or the given time interval has passed. Basically -this is a sub-second-resolution C<sleep ()>. +Sleep for the given interval: The current thread will be blocked +until either it is interrupted or the given time interval has +passed (approximately - it might return a bit earlier even if not +interrupted). Returns immediately if C<< interval <= 0 >>. + +Basically this is a sub-second-resolution C<sleep ()>. + +The range of the C<interval> is limited - libev only guarantees to work +with sleep times of up to one day (C<< interval <= 86400 >>). =item int ev_version_major () @@ -144,11 +144,13 @@ epoll_poll (EV_P_ ev_tstamp timeout) int i; int eventcnt; + if (expect_false (epoll_epermcnt)) + timeout = 0.; + /* epoll wait times cannot be larger than (LONG_MAX - 999UL) / HZ msecs, which is below */ /* the default libev max wait time, however. */ EV_RELEASE_CB; - eventcnt = epoll_wait (backend_fd, epoll_events, epoll_eventmax, - epoll_epermcnt ? 0 : ev_timeout_to_ms (timeout)); + eventcnt = epoll_wait (backend_fd, epoll_events, epoll_eventmax, timeout * 1e3); EV_ACQUIRE_CB; if (expect_false (eventcnt < 0)) @@ -92,7 +92,7 @@ poll_poll (EV_P_ ev_tstamp timeout) int res; EV_RELEASE_CB; - res = poll (polls, pollcnt, ev_timeout_to_ms (timeout)); + res = poll (polls, pollcnt, timeout * 1e3); EV_ACQUIRE_CB; if (expect_false (res < 0)) |