[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC v0 05/10] qemu-coroutine: Add simple work queue suppor
From: |
Peter A. G. Crosthwaite |
Subject: |
[Qemu-devel] [RFC v0 05/10] qemu-coroutine: Add simple work queue support |
Date: |
Mon, 17 Sep 2012 19:02:57 +1000 |
Add a function co_queue_enter_next() which will immediately transfer
control to the coroutine at the head of a co queue. This can be used for
implementing simple work queues where the manager of a co-queue only
needs to enter queued routines one at a time.
Signed-off-by: Peter A. G. Crosthwaite <address@hidden>
---
qemu-coroutine-lock.c | 13 +++++++++++++
qemu-coroutine.h | 9 +++++++++
2 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/qemu-coroutine-lock.c b/qemu-coroutine-lock.c
index 26ad76b..6e343b1 100644
--- a/qemu-coroutine-lock.c
+++ b/qemu-coroutine-lock.c
@@ -91,6 +91,19 @@ void qemu_co_queue_restart_all(CoQueue *queue)
}
}
+bool qemu_co_queue_enter_next(CoQueue *queue)
+{
+ Coroutine *next;
+
+ next = QTAILQ_FIRST(&queue->entries);
+ if (next) {
+ QTAILQ_REMOVE(&queue->entries, next, co_queue_next);
+ qemu_coroutine_enter(next, NULL);
+ }
+
+ return (next != NULL);
+}
+
bool qemu_co_queue_empty(CoQueue *queue)
{
return (QTAILQ_FIRST(&queue->entries) == NULL);
diff --git a/qemu-coroutine.h b/qemu-coroutine.h
index 34c15d4..d63b103 100644
--- a/qemu-coroutine.h
+++ b/qemu-coroutine.h
@@ -137,6 +137,15 @@ bool qemu_co_queue_next(CoQueue *queue);
void qemu_co_queue_restart_all(CoQueue *queue);
/**
+ * Transfers control to the next coroutine in the CoQueue and removes it from
+ * the queue.
+ *
+ * Returns true once after control transfers back to caller, or false
+ * immediately if the queue is empty.
+ */
+bool qemu_co_queue_enter_next(CoQueue *queue);
+
+/**
* Checks if the CoQueue is empty.
*/
bool qemu_co_queue_empty(CoQueue *queue);
--
1.7.0.4
- [Qemu-devel] [RFC v0 00/10] Microblaze generic FDT framework, Peter A. G. Crosthwaite, 2012/09/17
- [Qemu-devel] [RFC v0 01/10] device_tree: allow offsets for cell properties, Peter A. G. Crosthwaite, 2012/09/17
- [Qemu-devel] [RFC v0 02/10] device_tree: return Error* from prop getters, Peter A. G. Crosthwaite, 2012/09/17
- [Qemu-devel] [RFC v0 03/10] device_tree: allow property getters to inherit, Peter A. G. Crosthwaite, 2012/09/17
- [Qemu-devel] [RFC v0 04/10] device_tree: get_prop(): memdup returned properties, Peter A. G. Crosthwaite, 2012/09/17
- [Qemu-devel] [RFC v0 05/10] qemu-coroutine: Add simple work queue support,
Peter A. G. Crosthwaite <=
- [Qemu-devel] [RFC v0 08/10] pflash_cfi01: Added fdt generic platform support, Peter A. G. Crosthwaite, 2012/09/17
- [Qemu-devel] [RFC v0 09/10] microblaze_generic_fdt: first revision, Peter A. G. Crosthwaite, 2012/09/17
- [Qemu-devel] [RFC v0 07/10] fdt_generic: First revision, Peter A. G. Crosthwaite, 2012/09/17
- [Qemu-devel] [RFC v0 06/10] device_tree: Extended interface for fdt_generic, Peter A. G. Crosthwaite, 2012/09/17
- [Qemu-devel] [RFC v0 10/10] serial: added fdt generic platform support, Peter A. G. Crosthwaite, 2012/09/17