summaryrefslogtreecommitdiffstats
path: root/include/qemu
diff options
context:
space:
mode:
authorPaolo Bonzini2017-02-13 19:12:43 +0100
committerStefan Hajnoczi2017-02-21 12:39:40 +0100
commit1ace7ceac507d90d50ecb2e13f7222beadb64d92 (patch)
tree0a457dc7da86284d408e13ceefc764b914b90b41 /include/qemu
parentcoroutine-lock: place CoMutex before CoQueue in header (diff)
downloadqemu-1ace7ceac507d90d50ecb2e13f7222beadb64d92.tar.gz
qemu-1ace7ceac507d90d50ecb2e13f7222beadb64d92.tar.xz
qemu-1ace7ceac507d90d50ecb2e13f7222beadb64d92.zip
coroutine-lock: add mutex argument to CoQueue APIs
All that CoQueue needs in order to become thread-safe is help from an external mutex. Add this to the API. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com> Message-id: 20170213181244.16297-6-pbonzini@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'include/qemu')
-rw-r--r--include/qemu/coroutine.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/include/qemu/coroutine.h b/include/qemu/coroutine.h
index 9f685794d2..d2de268981 100644
--- a/include/qemu/coroutine.h
+++ b/include/qemu/coroutine.h
@@ -160,7 +160,8 @@ void coroutine_fn qemu_co_mutex_unlock(CoMutex *mutex);
/**
* CoQueues are a mechanism to queue coroutines in order to continue executing
- * them later.
+ * them later. They are similar to condition variables, but they need help
+ * from an external mutex in order to maintain thread-safety.
*/
typedef struct CoQueue {
QSIMPLEQ_HEAD(, Coroutine) entries;
@@ -174,9 +175,10 @@ void qemu_co_queue_init(CoQueue *queue);
/**
* Adds the current coroutine to the CoQueue and transfers control to the
- * caller of the coroutine.
+ * caller of the coroutine. The mutex is unlocked during the wait and
+ * locked again afterwards.
*/
-void coroutine_fn qemu_co_queue_wait(CoQueue *queue);
+void coroutine_fn qemu_co_queue_wait(CoQueue *queue, CoMutex *mutex);
/**
* Restarts the next coroutine in the CoQueue and removes it from the queue.