summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot <root>2011-06-04 05:25:02 +0000
committerroot <root>2011-06-04 05:25:02 +0000
commit436d5d174bfb936c4852a63eb03e0a3185f1502a (patch)
treec0f5297470af0fbe39b75963bad813f1f2a4fc3b
parenta9e3edbbaef8f747345cbaabb111219272ed1a53 (diff)
*** empty log message ***
-rw-r--r--Changes7
-rw-r--r--ev.c8
-rw-r--r--ev.pod12
-rw-r--r--ev_epoll.c6
-rw-r--r--ev_poll.c2
5 files changed, 19 insertions, 16 deletions
diff --git a/Changes b/Changes
index 9f72f8c..3b85a30 100644
--- a/Changes
+++ b/Changes
@@ -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
diff --git a/ev.c b/ev.c
index d92b0ed..c712f04 100644
--- a/ev.c
+++ b/ev.c
@@ -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 */
diff --git a/ev.pod b/ev.pod
index 4ac1d12..1e444cb 100644
--- a/ev.pod
+++ b/ev.pod
@@ -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 ()
diff --git a/ev_epoll.c b/ev_epoll.c
index 1b8a3e9..c8448da 100644
--- a/ev_epoll.c
+++ b/ev_epoll.c
@@ -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))
diff --git a/ev_poll.c b/ev_poll.c
index 7c7ece1..5f62bba 100644
--- a/ev_poll.c
+++ b/ev_poll.c
@@ -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))