aboutsummaryrefslogtreecommitdiff
path: root/aio-win32.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2014-07-09 11:53:07 +0200
committerStefan Hajnoczi <stefanha@redhat.com>2014-08-29 10:46:58 +0100
commit0a9dd1664a0509f7c3c0c7a5550446258ee70f4b (patch)
treecdc283c50561aacd9a0e9936be68449540719bc6 /aio-win32.c
parent363285d4b39cbd80427b4fb0a71266fef17290bf (diff)
aio-win32: add aio_set_dispatching optimization
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'aio-win32.c')
-rw-r--r--aio-win32.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/aio-win32.c b/aio-win32.c
index 1ec434a83c..fd526864be 100644
--- a/aio-win32.c
+++ b/aio-win32.c
@@ -144,12 +144,25 @@ bool aio_poll(AioContext *ctx, bool blocking)
{
AioHandler *node;
HANDLE events[MAXIMUM_WAIT_OBJECTS + 1];
- bool progress, first;
+ bool was_dispatching, progress, first;
int count;
int timeout;
+ was_dispatching = ctx->dispatching;
progress = false;
+ /* aio_notify can avoid the expensive event_notifier_set if
+ * everything (file descriptors, bottom halves, timers) will
+ * be re-evaluated before the next blocking poll(). This is
+ * already true when aio_poll is called with blocking == false;
+ * if blocking == true, it is only true after poll() returns.
+ *
+ * If we're in a nested event loop, ctx->dispatching might be true.
+ * In that case we can restore it just before returning, but we
+ * have to clear it now.
+ */
+ aio_set_dispatching(ctx, !blocking);
+
ctx->walking_handlers++;
/* fill fd sets */
@@ -170,6 +183,7 @@ bool aio_poll(AioContext *ctx, bool blocking)
timeout = blocking
? qemu_timeout_ns_to_ms(aio_compute_timeout(ctx)) : 0;
ret = WaitForMultipleObjects(count, events, FALSE, timeout);
+ aio_set_dispatching(ctx, true);
if (first && aio_bh_poll(ctx)) {
progress = true;
@@ -191,5 +205,6 @@ bool aio_poll(AioContext *ctx, bool blocking)
progress |= timerlistgroup_run_timers(&ctx->tlg);
+ aio_set_dispatching(ctx, was_dispatching);
return progress;
}