[Tarantool-patches] [PATCH v8 1/6] latch: add latch_is_locked helper
Cyrill Gorcunov
gorcunov at gmail.com
Mon Jul 26 18:34:47 MSK 2021
To test if latch is locked.
In-scope-of #6036
Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
---
src/lib/core/latch.h | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/src/lib/core/latch.h b/src/lib/core/latch.h
index 49c59cf63..0aaa8b634 100644
--- a/src/lib/core/latch.h
+++ b/src/lib/core/latch.h
@@ -95,6 +95,17 @@ latch_owner(struct latch *l)
return l->owner;
}
+/**
+ * Return true if the latch is locked.
+ *
+ * @param l - latch to be tested.
+ */
+static inline bool
+latch_is_locked(const struct latch *l)
+{
+ return l->owner != NULL;
+}
+
/**
* Lock a latch. If the latch is already locked by another fiber,
* waits for timeout.
--
2.31.1
More information about the Tarantool-patches
mailing list