[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 22/24] coroutine-lock: place CoMutex before CoQueue i
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PULL 22/24] coroutine-lock: place CoMutex before CoQueue in header |
Date: |
Mon, 20 Feb 2017 09:33:02 +0000 |
From: Paolo Bonzini <address@hidden>
This will avoid forward references in the next patch. It is also
more logical because CoQueue is not anymore the basic primitive.
Signed-off-by: Paolo Bonzini <address@hidden>
Reviewed-by: Fam Zheng <address@hidden>
Message-id: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
include/qemu/coroutine.h | 89 ++++++++++++++++++++++++------------------------
1 file changed, 44 insertions(+), 45 deletions(-)
diff --git a/include/qemu/coroutine.h b/include/qemu/coroutine.h
index 12ce8e1..9f68579 100644
--- a/include/qemu/coroutine.h
+++ b/include/qemu/coroutine.h
@@ -112,51 +112,6 @@ bool qemu_in_coroutine(void);
*/
bool qemu_coroutine_entered(Coroutine *co);
-
-/**
- * CoQueues are a mechanism to queue coroutines in order to continue executing
- * them later. They provide the fundamental primitives on which coroutine locks
- * are built.
- */
-typedef struct CoQueue {
- QSIMPLEQ_HEAD(, Coroutine) entries;
-} CoQueue;
-
-/**
- * Initialise a CoQueue. This must be called before any other operation is used
- * on the CoQueue.
- */
-void qemu_co_queue_init(CoQueue *queue);
-
-/**
- * Adds the current coroutine to the CoQueue and transfers control to the
- * caller of the coroutine.
- */
-void coroutine_fn qemu_co_queue_wait(CoQueue *queue);
-
-/**
- * Restarts the next coroutine in the CoQueue and removes it from the queue.
- *
- * Returns true if a coroutine was restarted, false if the queue is empty.
- */
-bool coroutine_fn qemu_co_queue_next(CoQueue *queue);
-
-/**
- * Restarts all coroutines in the CoQueue and leaves the queue empty.
- */
-void coroutine_fn qemu_co_queue_restart_all(CoQueue *queue);
-
-/**
- * Enter the next coroutine in the queue
- */
-bool qemu_co_enter_next(CoQueue *queue);
-
-/**
- * Checks if the CoQueue is empty.
- */
-bool qemu_co_queue_empty(CoQueue *queue);
-
-
/**
* Provides a mutex that can be used to synchronise coroutines
*/
@@ -202,6 +157,50 @@ void coroutine_fn qemu_co_mutex_lock(CoMutex *mutex);
*/
void coroutine_fn qemu_co_mutex_unlock(CoMutex *mutex);
+
+/**
+ * CoQueues are a mechanism to queue coroutines in order to continue executing
+ * them later.
+ */
+typedef struct CoQueue {
+ QSIMPLEQ_HEAD(, Coroutine) entries;
+} CoQueue;
+
+/**
+ * Initialise a CoQueue. This must be called before any other operation is used
+ * on the CoQueue.
+ */
+void qemu_co_queue_init(CoQueue *queue);
+
+/**
+ * Adds the current coroutine to the CoQueue and transfers control to the
+ * caller of the coroutine.
+ */
+void coroutine_fn qemu_co_queue_wait(CoQueue *queue);
+
+/**
+ * Restarts the next coroutine in the CoQueue and removes it from the queue.
+ *
+ * Returns true if a coroutine was restarted, false if the queue is empty.
+ */
+bool coroutine_fn qemu_co_queue_next(CoQueue *queue);
+
+/**
+ * Restarts all coroutines in the CoQueue and leaves the queue empty.
+ */
+void coroutine_fn qemu_co_queue_restart_all(CoQueue *queue);
+
+/**
+ * Enter the next coroutine in the queue
+ */
+bool qemu_co_enter_next(CoQueue *queue);
+
+/**
+ * Checks if the CoQueue is empty.
+ */
+bool qemu_co_queue_empty(CoQueue *queue);
+
+
typedef struct CoRwlock {
bool writer;
int reader;
--
2.9.3
- [Qemu-devel] [PULL 10/24] qed: introduce qed_aio_start_io and qed_aio_next_io_cb, (continued)
- [Qemu-devel] [PULL 10/24] qed: introduce qed_aio_start_io and qed_aio_next_io_cb, Stefan Hajnoczi, 2017/02/20
- [Qemu-devel] [PULL 11/24] aio: push aio_context_acquire/release down to dispatching, Stefan Hajnoczi, 2017/02/20
- [Qemu-devel] [PULL 12/24] block: explicitly acquire aiocontext in timers that need it, Stefan Hajnoczi, 2017/02/20
- [Qemu-devel] [PULL 13/24] block: explicitly acquire aiocontext in callbacks that need it, Stefan Hajnoczi, 2017/02/20
- [Qemu-devel] [PULL 14/24] block: explicitly acquire aiocontext in bottom halves that need it, Stefan Hajnoczi, 2017/02/20
- [Qemu-devel] [PULL 15/24] block: explicitly acquire aiocontext in aio callbacks that need it, Stefan Hajnoczi, 2017/02/20
- [Qemu-devel] [PULL 16/24] aio-posix: partially inline aio_dispatch into aio_poll, Stefan Hajnoczi, 2017/02/20
- [Qemu-devel] [PULL 18/24] block: document fields protected by AioContext lock, Stefan Hajnoczi, 2017/02/20
- [Qemu-devel] [PULL 17/24] async: remove unnecessary inc/dec pairs, Stefan Hajnoczi, 2017/02/20
- [Qemu-devel] [PULL 20/24] coroutine-lock: add limited spinning to CoMutex, Stefan Hajnoczi, 2017/02/20
- [Qemu-devel] [PULL 22/24] coroutine-lock: place CoMutex before CoQueue in header,
Stefan Hajnoczi <=
- [Qemu-devel] [PULL 19/24] coroutine-lock: make CoMutex thread-safe, Stefan Hajnoczi, 2017/02/20
- [Qemu-devel] [PULL 24/24] coroutine-lock: make CoRwlock thread-safe and fair, Stefan Hajnoczi, 2017/02/20
- [Qemu-devel] [PULL 21/24] test-aio-multithread: add performance comparison with thread-based mutexes, Stefan Hajnoczi, 2017/02/20
- [Qemu-devel] [PULL 23/24] coroutine-lock: add mutex argument to CoQueue APIs, Stefan Hajnoczi, 2017/02/20
- Re: [Qemu-devel] [PULL 00/24] Block patches, Peter Maydell, 2017/02/20