diff mbox

[PATCHv2,RFC,5/7] aio / timers: Add a clock to AioContext

Message ID 1374343603-29183-6-git-send-email-alex@alex.org.uk
State New
Headers show

Commit Message

Alex Bligh July 20, 2013, 6:06 p.m. UTC
Add a clock to each AioContext and delete it when freed.

Signed-off-by: Alex Bligh <alex@alex.org.uk>
---
 async.c             |    2 ++
 include/block/aio.h |    5 +++++
 2 files changed, 7 insertions(+)
diff mbox

Patch

diff --git a/async.c b/async.c
index 90fe906..0d41431 100644
--- a/async.c
+++ b/async.c
@@ -177,6 +177,7 @@  aio_ctx_finalize(GSource     *source)
     aio_set_event_notifier(ctx, &ctx->notifier, NULL, NULL);
     event_notifier_cleanup(&ctx->notifier);
     g_array_free(ctx->pollfds, TRUE);
+    qemu_free_clock(ctx->clock);
 }
 
 static GSourceFuncs aio_source_funcs = {
@@ -215,6 +216,7 @@  AioContext *aio_context_new(void)
     aio_set_event_notifier(ctx, &ctx->notifier, 
                            (EventNotifierHandler *)
                            event_notifier_test_and_clear, NULL);
+    ctx->clock = qemu_new_clock(QEMU_CLOCK_REALTIME);
 
     return ctx;
 }
diff --git a/include/block/aio.h b/include/block/aio.h
index 1836793..0835a4d 100644
--- a/include/block/aio.h
+++ b/include/block/aio.h
@@ -41,6 +41,8 @@  typedef struct AioHandler AioHandler;
 typedef void QEMUBHFunc(void *opaque);
 typedef void IOHandler(void *opaque);
 
+typedef struct QEMUClock QEMUClock;
+
 typedef struct AioContext {
     GSource source;
 
@@ -69,6 +71,9 @@  typedef struct AioContext {
 
     /* Thread pool for performing work and receiving completion callbacks */
     struct ThreadPool *thread_pool;
+
+    /* Clock for calling timers */
+    QEMUClock *clock;
 } AioContext;
 
 /* Returns 1 if there are still outstanding AIO requests; 0 otherwise */