From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 6D99E6EC58; Wed, 4 Aug 2021 22:08:29 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 6D99E6EC58 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1628104109; bh=NiGfM8PVynnVxt6ye9ls291XyUU3GGuDvaXaxGh7gUM=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=TxDk5RQgrb/JBwDgbEddIbU4WrcL9mUIme6LWPQa+0YtbdIQ36D0APFfWiPZZwzOg W82Od8TfI8ywzCp5iuvmqQcNmCbLCmvUdk3wPN4omRret7zRHt3ILyn8+ErcBoVLJW Yi1pCWTnCErPNlGl5CfhnzXV1b8aZ29z69EPbsgM= Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 322D66EC58 for ; Wed, 4 Aug 2021 22:08:09 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 322D66EC58 Received: by mail-lj1-f172.google.com with SMTP id l4so3771186ljq.4 for ; Wed, 04 Aug 2021 12:08:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HRHB/wJMv7SarpTzSEPo5NGoWJZ2kDL0BPHhd7Wnba4=; b=lOwnIx8z2tQg0kzJZG6ef31JfG7/pJ4zj74NesSlcaSUEc3QJJoVWxaYPyP1Zi32o7 c8cwUQDyEaUT3shQWwaVxHUBak7NkCtkuRGYLBN37zeDNdxKB0fH9iX+oPIM3wHkIILY ZYHiY9sBHNFXVgG6Fjd6XnRxMND7rDFYjIRdFj0RKYIlpRMuJ5B780hY/bsUFFIs7LTC 4/vQYkMFZkp8Aei9wRI9PCkJ1Ik+s1peSF89QLH1U2ENYl2rp2eGUhhi6wPXq6sygWAn fEaVLRfBo1lnAfV7WrAF1584WWitol0xYGa9Mq02gbE5mktIanOrwXqjAN5dCMDO9qUV 3gsg== X-Gm-Message-State: AOAM532dorBcf4SyknNUPaFTCWj1Z4UF8LbKDZl12v0r/O2kwawaxJ0B OF3kRTYWSIbPxZfLWrzkZrfsTa9KCeI= X-Google-Smtp-Source: ABdhPJxzBHI8zGxCWqnop1c4EV1uI9G6hlwwo7C8aXsWhzEA5CSs39UFEtKgOX2wR5MP9Xg4zYM26Q== X-Received: by 2002:a2e:8513:: with SMTP id j19mr6492lji.448.1628104088173; Wed, 04 Aug 2021 12:08:08 -0700 (PDT) Received: from grain.localdomain ([5.18.255.97]) by smtp.gmail.com with ESMTPSA id h34sm274824lfv.231.2021.08.04.12.08.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Aug 2021 12:08:07 -0700 (PDT) Received: by grain.localdomain (Postfix, from userid 1000) id D55565A001D; Wed, 4 Aug 2021 22:07:53 +0300 (MSK) To: tml Date: Wed, 4 Aug 2021 22:07:49 +0300 Message-Id: <20210804190752.488147-2-gorcunov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210804190752.488147-1-gorcunov@gmail.com> References: <20210804190752.488147-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH v10 1/4] latch: add latch_is_locked helper X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Cyrill Gorcunov via Tarantool-patches Reply-To: Cyrill Gorcunov Cc: Vladislav Shpilevoy Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" To test if latch is locked. In-scope-of #6036 Signed-off-by: Cyrill Gorcunov --- 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