From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55476) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V0bYa-0003zc-5R for qemu-devel@nongnu.org; Sat, 20 Jul 2013 14:07:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V0bYX-00082h-6O for qemu-devel@nongnu.org; Sat, 20 Jul 2013 14:07:00 -0400 Received: from mail.avalus.com ([2001:41c8:10:1dd::10]:53940) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V0bYW-00082T-VV for qemu-devel@nongnu.org; Sat, 20 Jul 2013 14:06:57 -0400 From: Alex Bligh Date: Sat, 20 Jul 2013 19:06:40 +0100 Message-Id: <1374343603-29183-5-git-send-email-alex@alex.org.uk> In-Reply-To: <1374343603-29183-1-git-send-email-alex@alex.org.uk> References: <1E8E204.8000201@redhat.com> <1374343603-29183-1-git-send-email-alex@alex.org.uk> Subject: [Qemu-devel] [PATCHv2] [RFC 4/7] aio / timers: Make qemu_run_timers and qemu_run_all_timers return progress List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Anthony Liguori , Alex Bligh , Stefan Hajnoczi , Paolo Bonzini , rth@twiddle.net Make qemu_run_timers and qemu_run_all_timers return progress so that aio_poll etc. can determine whether a timer has been run. Signed-off-by: Alex Bligh --- include/qemu/timer.h | 4 ++-- qemu-timer.c | 17 +++++++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/include/qemu/timer.h b/include/qemu/timer.h index 2f1b609..e0922e6 100644 --- a/include/qemu/timer.h +++ b/include/qemu/timer.h @@ -63,8 +63,8 @@ bool qemu_timer_pending(QEMUTimer *ts); bool qemu_timer_expired(QEMUTimer *timer_head, int64_t current_time); uint64_t qemu_timer_expire_time_ns(QEMUTimer *ts); -void qemu_run_timers(QEMUClock *clock); -void qemu_run_all_timers(void); +bool qemu_run_timers(QEMUClock *clock); +bool qemu_run_all_timers(void); void init_clocks(void); int64_t cpu_get_ticks(void); diff --git a/qemu-timer.c b/qemu-timer.c index 5c576b4..4cba055 100644 --- a/qemu-timer.c +++ b/qemu-timer.c @@ -299,13 +299,14 @@ bool qemu_timer_expired(QEMUTimer *timer_head, int64_t current_time) return qemu_timer_expired_ns(timer_head, current_time * timer_head->scale); } -void qemu_run_timers(QEMUClock *clock) +bool qemu_run_timers(QEMUClock *clock) { QEMUTimer *ts; int64_t current_time; + bool progress = false; if (!clock->enabled) - return; + return progress; current_time = qemu_get_clock_ns(clock); for(;;) { @@ -319,7 +320,9 @@ void qemu_run_timers(QEMUClock *clock) /* run the callback (the timer list can be modified) */ ts->cb(ts->opaque); + progress = true; } + return progress; } int64_t qemu_get_clock_ns(QEMUClock *clock) @@ -371,10 +374,12 @@ uint64_t qemu_timer_expire_time_ns(QEMUTimer *ts) return qemu_timer_pending(ts) ? ts->expire_time : -1; } -void qemu_run_all_timers(void) +bool qemu_run_all_timers(void) { /* vm time timers */ - qemu_run_timers(vm_clock); - qemu_run_timers(rt_clock); - qemu_run_timers(host_clock); + bool progress = false; + progress |= qemu_run_timers(vm_clock); + progress |= qemu_run_timers(rt_clock); + progress |= qemu_run_timers(host_clock); + return progress; } -- 1.7.9.5