[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/3] coroutine: Add qemu_co_mutex_assert_locked()
From: |
Kevin Wolf |
Subject: |
[PATCH 1/3] coroutine: Add qemu_co_mutex_assert_locked() |
Date: |
Wed, 23 Oct 2019 17:26:18 +0200 |
Some functions require that the caller holds a certain CoMutex for them
to operate correctly. Add a function so that they can assert the lock is
really held.
Cc: address@hidden
Signed-off-by: Kevin Wolf <address@hidden>
---
include/qemu/coroutine.h | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/include/qemu/coroutine.h b/include/qemu/coroutine.h
index 9801e7f5a4..a36bcfe5c8 100644
--- a/include/qemu/coroutine.h
+++ b/include/qemu/coroutine.h
@@ -167,6 +167,13 @@ void coroutine_fn qemu_co_mutex_lock(CoMutex *mutex);
*/
void coroutine_fn qemu_co_mutex_unlock(CoMutex *mutex);
+/**
+ * Assert that the current coroutine holds @mutex.
+ */
+static inline coroutine_fn void qemu_co_mutex_assert_locked(CoMutex *mutex)
+{
+ assert(mutex->locked && mutex->holder == qemu_coroutine_self());
+}
/**
* CoQueues are a mechanism to queue coroutines in order to continue executing
--
2.20.1