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 BD80E6EC40; Wed, 22 Sep 2021 16:06:21 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org BD80E6EC40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1632315981; bh=Za/4NMMyA2NoZBVsKBz6wrk2ouRxHPgOMH/cnPLKnXs=; 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=CIDd9IsIi7VpXpnM0Y120IuFz4eL2qv2GGxez27Eu67YK5sga0o10NYgTKTe3ORwy hyjsnpe3syb/9nImCJgmldQpkBEND5uo5m/euepdTor++Fx+NsIY7P3D/L0TbSplEE HyON97D2wk00wMhEYWKd5Hi+NATu6uu25DYPwKwg= Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) (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 668CE6EC40 for ; Wed, 22 Sep 2021 16:05:59 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 668CE6EC40 Received: by mail-lf1-f46.google.com with SMTP id e15so11532210lfr.10 for ; Wed, 22 Sep 2021 06:05:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WQRXak4ndiQ8ssRvSybhpjPPGpaFF3TXs5ZHDJaf2gU=; b=prkefbnTqy9KK8ljtHFlg/yCNsWBgQO+UnNMqlLk8xbPUDXoVN2bhp0lPkCcXQGsKt wuAaJP78u5CpPbJfY88WMaaOU4S6q3Li5Rp0h56+ia8h7zJH7nvNy86B6gi7k/6b39gv g2izjkp8pvG821M5KLPTND1pFI2maSuuLGtN4kNIPwpiqhzGSACfaDSzljjrNT1q13uQ I6BolAYM5+t40Di3hX3Qvbi5kk5CW0PgZoXlr9te0nnn14qL0bCycnzV15nEqsErz++v +kVBzQwtMspTwjV2jcwnk89AC66jgMtGebU28BncSn5MemezzkSSQ/2PiTIIRKe8Rx+0 tc6g== X-Gm-Message-State: AOAM531vb+Y7rhDJIK4QF7q9aRLb5Kwr22UAB2/K22fpP5YULdhpw0rQ XcbHUfr9LLDi86z8s2hti8/ParPQTUGPXw== X-Google-Smtp-Source: ABdhPJyxF4UOFai/l7tY6rTZ7I9tezehe3ZGPPtT/7GsOeYSUwM9kS6p1J7llF18t2aBJcden+1kpw== X-Received: by 2002:a2e:7516:: with SMTP id q22mr34046179ljc.265.1632315949676; Wed, 22 Sep 2021 06:05:49 -0700 (PDT) Received: from grain.localdomain ([5.18.253.97]) by smtp.gmail.com with ESMTPSA id z26sm183227lfg.300.2021.09.22.06.05.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Sep 2021 06:05:48 -0700 (PDT) Received: by grain.localdomain (Postfix, from userid 1000) id 48BC25A001D; Wed, 22 Sep 2021 16:05:36 +0300 (MSK) To: tml Date: Wed, 22 Sep 2021 16:05:31 +0300 Message-Id: <20210922130535.79479-2-gorcunov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210922130535.79479-1-gorcunov@gmail.com> References: <20210922130535.79479-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH v17 1/5] 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. Part-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