summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot <root>2008-10-01 04:25:25 +0000
committerroot <root>2008-10-01 04:25:25 +0000
commit03ba7182d3e525203cd8535ce154a94242a6f511 (patch)
treec2da22108976f524657e0885a88a19bc034a6617
parentc53135daec2ac56c937fc5d516031ecbaebdb956 (diff)
*** empty log message ***
-rw-r--r--Changes5
-rw-r--r--ev.c8
-rw-r--r--ev.pod15
3 files changed, 19 insertions, 9 deletions
diff --git a/Changes b/Changes
index 44820e2..10a2086 100644
--- a/Changes
+++ b/Changes
@@ -1,7 +1,10 @@
Revision history for libev, a high-performance and full-featured event loop.
WISH? monotonic clocks times/GetTickCount for coarse corrections?
-TODO: make ev_once timeout=0 useful, and make I/O always win.
+
+ - ev_once now passes both timeout and io to the callback if both
+ occur concurrently, instead of giving timeouts precedence.
+
3.44 Mon Sep 29 05:18:39 CEST 2008
- embed watchers now automatically invoke ev_loop_fork on the
embedded loop when the parent loop forks.
diff --git a/ev.c b/ev.c
index b20112e..4e86506 100644
--- a/ev.c
+++ b/ev.c
@@ -3014,13 +3014,17 @@ once_cb (EV_P_ struct ev_once *once, int revents)
static void
once_cb_io (EV_P_ ev_io *w, int revents)
{
- once_cb (EV_A_ (struct ev_once *)(((char *)w) - offsetof (struct ev_once, io)), revents);
+ struct ev_once *once = (struct ev_once *)(((char *)w) - offsetof (struct ev_once, io));
+
+ once_cb (EV_A_ once, revents | ev_clear_pending (EV_A_ &once->to));
}
static void
once_cb_to (EV_P_ ev_timer *w, int revents)
{
- once_cb (EV_A_ (struct ev_once *)(((char *)w) - offsetof (struct ev_once, to)), revents);
+ struct ev_once *once = (struct ev_once *)(((char *)w) - offsetof (struct ev_once, to));
+
+ once_cb (EV_A_ once, revents | ev_clear_pending (EV_A_ &once->io));
}
void
diff --git a/ev.pod b/ev.pod
index a3b3467..f6b466f 100644
--- a/ev.pod
+++ b/ev.pod
@@ -2515,20 +2515,23 @@ the given C<fd> and C<events> set will be created and started.
If C<timeout> is less than 0, then no timeout watcher will be
started. Otherwise an C<ev_timer> watcher with after = C<timeout> (and
-repeat = 0) will be started. While C<0> is a valid timeout, it is of
-dubious value.
+repeat = 0) will be started. C<0> is a valid timeout.
The callback has the type C<void (*cb)(int revents, void *arg)> and gets
passed an C<revents> set like normal event callbacks (a combination of
C<EV_ERROR>, C<EV_READ>, C<EV_WRITE> or C<EV_TIMEOUT>) and the C<arg>
-value passed to C<ev_once>:
+value passed to C<ev_once>. Note that it is possible to receive I<both>
+a timeout and an io event at the same time - you probably should give io
+events precedence.
+
+Example: wait up to ten seconds for data to appear on STDIN_FILENO.
static void stdin_ready (int revents, void *arg)
{
- if (revents & EV_TIMEOUT)
- /* doh, nothing entered */;
- else if (revents & EV_READ)
+ if (revents & EV_READ)
/* stdin might have data for us, joy! */;
+ else if (revents & EV_TIMEOUT)
+ /* doh, nothing entered */;
}
ev_once (STDIN_FILENO, EV_READ, 10., stdin_ready, 0);