coroutine: Drop co_sleep_ns
authorFam Zheng <famz@redhat.com>
Tue, 26 Aug 2014 07:15:43 +0000 (15:15 +0800)
committerStefan Hajnoczi <stefanha@redhat.com>
Fri, 29 Aug 2014 09:46:58 +0000 (10:46 +0100)
block_job_sleep_ns is the only user. Since we are moving towards
AioContext aware code, it's better to use the explicit version and drop
the old one.

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: BenoƮt Canet <benoit.canet@nodalink.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
blockjob.c
include/block/coroutine.h
qemu-coroutine-sleep.c

index ca0b4e25d066d66cfd6a00fa987b276787dc088d..0689fdd2b55c700100800a2acbbe34d6fd92a8fd 100644 (file)
@@ -205,7 +205,7 @@ void block_job_sleep_ns(BlockJob *job, QEMUClockType type, int64_t ns)
     if (block_job_is_paused(job)) {
         qemu_coroutine_yield();
     } else {
-        co_sleep_ns(type, ns);
+        co_aio_sleep_ns(bdrv_get_aio_context(job->bs), type, ns);
     }
     job->busy = true;
 }
index b9b7f488c91580d171f6115e5e1e5c96955d6a03..793df0ef8bdffe20e262df3a3b04f328bfaaac9e 100644 (file)
@@ -200,14 +200,6 @@ void qemu_co_rwlock_wrlock(CoRwlock *lock);
  */
 void qemu_co_rwlock_unlock(CoRwlock *lock);
 
-/**
- * Yield the coroutine for a given duration
- *
- * Note this function uses timers and hence only works when a main loop is in
- * use.  See main-loop.h and do not use from qemu-tool programs.
- */
-void coroutine_fn co_sleep_ns(QEMUClockType type, int64_t ns);
-
 /**
  * Yield the coroutine for a given duration
  *
index ad78fbaa2a904597803148984f531dd88d97f8b9..9abb7fdf31a96118c6c2b822225fa3d7074cecc7 100644 (file)
@@ -27,18 +27,6 @@ static void co_sleep_cb(void *opaque)
     qemu_coroutine_enter(sleep_cb->co, NULL);
 }
 
-void coroutine_fn co_sleep_ns(QEMUClockType type, int64_t ns)
-{
-    CoSleepCB sleep_cb = {
-        .co = qemu_coroutine_self(),
-    };
-    sleep_cb.ts = timer_new(type, SCALE_NS, co_sleep_cb, &sleep_cb);
-    timer_mod(sleep_cb.ts, qemu_clock_get_ns(type) + ns);
-    qemu_coroutine_yield();
-    timer_del(sleep_cb.ts);
-    timer_free(sleep_cb.ts);
-}
-
 void coroutine_fn co_aio_sleep_ns(AioContext *ctx, QEMUClockType type,
                                   int64_t ns)
 {