[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC] [PATCHv8 12/30] aio / timers: aio_ctx_prepare sets ti
From: |
Alex Bligh |
Subject: |
[Qemu-devel] [RFC] [PATCHv8 12/30] aio / timers: aio_ctx_prepare sets timeout from AioContext timers |
Date: |
Thu, 8 Aug 2013 22:42:09 +0100 |
Calculate the timeout in aio_ctx_prepare taking into account
the timers attached to the AioContext.
Alter aio_ctx_check similarly.
Signed-off-by: Alex Bligh <address@hidden>
---
async.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/async.c b/async.c
index 2051921..dd27459 100644
--- a/async.c
+++ b/async.c
@@ -150,13 +150,14 @@ aio_ctx_prepare(GSource *source, gint *timeout)
{
AioContext *ctx = (AioContext *) source;
QEMUBH *bh;
+ int deadline;
for (bh = ctx->first_bh; bh; bh = bh->next) {
if (!bh->deleted && bh->scheduled) {
if (bh->idle) {
/* idle bottom halves will be polled at least
* every 10ms */
- *timeout = 10;
+ *timeout = qemu_soonest_timeout(*timeout, 10);
} else {
/* non-idle bottom halves will be executed
* immediately */
@@ -166,6 +167,14 @@ aio_ctx_prepare(GSource *source, gint *timeout)
}
}
+ deadline = qemu_timeout_ns_to_ms(timerlistgroup_deadline_ns(ctx->tlg));
+ if (deadline == 0) {
+ *timeout = 0;
+ return true;
+ } else {
+ *timeout = qemu_soonest_timeout(*timeout, deadline);
+ }
+
return false;
}
@@ -180,7 +189,7 @@ aio_ctx_check(GSource *source)
return true;
}
}
- return aio_pending(ctx);
+ return aio_pending(ctx) || (timerlistgroup_deadline_ns(ctx->tlg) == 0);
}
static gboolean
--
1.7.9.5
- Re: [Qemu-devel] [RFC] [PATCHv8 09/30] aio / timers: Add QEMUTimerListGroup and helper functions, (continued)
[Qemu-devel] [RFC] [PATCHv8 02/30] aio / timers: add qemu-timer.c utility functions, Alex Bligh, 2013/08/08
[Qemu-devel] [RFC] [PATCHv8 10/30] aio / timers: Add QEMUTimerListGroup to AioContext, Alex Bligh, 2013/08/08
[Qemu-devel] [RFC] [PATCHv8 11/30] aio / timers: Add a notify callback to QEMUTimerList, Alex Bligh, 2013/08/08
[Qemu-devel] [RFC] [PATCHv8 12/30] aio / timers: aio_ctx_prepare sets timeout from AioContext timers,
Alex Bligh <=
[Qemu-devel] [RFC] [PATCHv8 13/30] aio / timers: Add aio_timer_new wrapper, Alex Bligh, 2013/08/08