Tarantool development patches archive
 help / color / mirror / Atom feed
From: Cyrill Gorcunov via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: tml <tarantool-patches@dev.tarantool.org>
Cc: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Subject: [Tarantool-patches] [PATCH v32 1/2] latch: add latch_is_locked helper
Date: Fri,  4 Mar 2022 09:01:04 +0300	[thread overview]
Message-ID: <20220304060105.1186867-2-gorcunov@gmail.com> (raw)
In-Reply-To: <20220304060105.1186867-1-gorcunov@gmail.com>

To test if latch is locked.

Part-of #6036

NO_DOC=Internal helper for next patch
NO_CHANGELOG=Internal helper for next patch

Acked-by: Serge Petrenko <sergepetrenko@tarantool.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@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.35.1


  reply	other threads:[~2022-03-04  6:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-04  6:01 [Tarantool-patches] [PATCH v32 0/2] qsync: implement packet filtering (part 1) Cyrill Gorcunov via Tarantool-patches
2022-03-04  6:01 ` Cyrill Gorcunov via Tarantool-patches [this message]
2022-03-04  6:01 ` [Tarantool-patches] [PATCH v32 2/2] qsync: order access to the limbo terms Cyrill Gorcunov via Tarantool-patches
2022-03-04  7:11 ` [Tarantool-patches] [PATCH v32 0/2] qsync: implement packet filtering (part 1) Serge Petrenko via Tarantool-patches
2022-03-04  9:34   ` Cyrill Gorcunov via Tarantool-patches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220304060105.1186867-2-gorcunov@gmail.com \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=gorcunov@gmail.com \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v32 1/2] latch: add latch_is_locked helper' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox