aboutsummaryrefslogtreecommitdiff
path: root/lib/poll-loop.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2010-05-12 12:53:07 -0700
committerBen Pfaff <blp@nicira.com>2010-05-26 11:46:59 -0700
commit7cf8b2660f9813fe080a3f4fcc975099cb36417a (patch)
treee508a0001469854f18e185c7b93b79af06c9906d /lib/poll-loop.c
parent8bf4bbe390af3f370e7e95d9237572ff750047a8 (diff)
poll-loop: New function poll_timer_wait_until().
Many of poll_timer_wait()'s callers actually want to wait until a specific time, so it's convenient for them to offer a function that does this.
Diffstat (limited to 'lib/poll-loop.c')
-rw-r--r--lib/poll-loop.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/poll-loop.c b/lib/poll-loop.c
index 29931f78..91034b04 100644
--- a/lib/poll-loop.c
+++ b/lib/poll-loop.c
@@ -100,6 +100,23 @@ poll_timer_wait(long long int msec)
: msec);
}
+/* Causes the following call to poll_block() to wake up when the current time,
+ * as returned by time_msec(), reaches 'msec' or later. If 'msec' is earlier
+ * than the current time, the following call to poll_block() will not block at
+ * all.
+ *
+ * The timer registration is one-shot: only the following call to poll_block()
+ * is affected. The timer will need to be re-registered after poll_block() is
+ * called if it is to persist. */
+void
+poll_timer_wait_until(long long int msec)
+{
+ long long int now = time_msec();
+ poll_timer_wait__(msec <= now ? 0
+ : msec < now + INT_MAX ? msec - now
+ : INT_MAX);
+}
+
/* Causes the following call to poll_block() to wake up immediately, without
* blocking. */
void