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 F0CD26E454; Thu, 24 Feb 2022 23:19:17 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org F0CD26E454 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1645733958; bh=vjhJG/qPxW1WZs1mBmDJU8lMPDLwDywxZl25lDKoGp4=; 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=MEVJmliWjmpVAJTpiJmBHRfQLQVYPmOOP8w7BF6+8udG619Wct/DhhEpBjYAkEvGG n/SwnsZ6zG8IDj87PtcdZn+P16FnmADKevMnteBTWTht07Xmut9QVEYUFEXgV4/E/F gX286PDGCYAm1YD2Z+/nxqaBgQUwN48wP01Ch+/s= Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) (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 70C1C6E454 for ; Thu, 24 Feb 2022 23:18:56 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 70C1C6E454 Received: by mail-lf1-f43.google.com with SMTP id m14so5841052lfu.4 for ; Thu, 24 Feb 2022 12:18:56 -0800 (PST) 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=qsCj2+PxBnRLzhNaBDd7y2VgVyVe6acxNiRhk72cWzo=; b=ctqBIsOgnD3UIHWbpvzK8OrKBYdBcm0lsQy/JPmryf8J713xnrPH9P12VM/+tnaCth 4CP/Cy3ES3RZIDFPWSiisAdWrW7qtwls9/Nkl2eVEk62uBKjabN2oI3Jia3rku2otJ6a FmWVfjd8/xnPE5Veclgtmf4p0hTD0szUnwtcEROwnyYHiu/HkFyG6MpS93vKP1yS0iL/ FLKyM6KQ5bRZMZwEPM3t96u8TxJ+z4jmBUIK0mcruJTczOitRHcXfGtB2o/AODjwFMT6 QAty8FdaQE2XNyIhHpnhvcuR0PoTuYI44YAzbpme/qxfo3wWPCVp5iOt+567hw8yY9ux BPBA== X-Gm-Message-State: AOAM531AnlWwsCgATd57rgNXaBwl22V/NAUZwuIpCQ3tJG+71O4cg5Cs 7pOziH7l++eTuQ7dOoARMjU687Yj51A= X-Google-Smtp-Source: ABdhPJzGH5eGV2uv2arnbb/BsCV7oGGqKggxCE9+Hq/XG+5PU3fmFdU1Vhdb2qechFcCe144VurpAA== X-Received: by 2002:a19:691c:0:b0:443:9a02:35d with SMTP id e28-20020a19691c000000b004439a02035dmr2818175lfc.541.1645733935417; Thu, 24 Feb 2022 12:18:55 -0800 (PST) Received: from grain.localdomain ([5.18.251.97]) by smtp.gmail.com with ESMTPSA id p41-20020a05651213a900b00443e2c39fc4sm19390lfa.111.2022.02.24.12.18.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 12:18:54 -0800 (PST) Received: by grain.localdomain (Postfix, from userid 1000) id 3C6F85A001F; Thu, 24 Feb 2022 23:18:42 +0300 (MSK) To: tml Date: Thu, 24 Feb 2022 23:18:39 +0300 Message-Id: <20220224201841.412565-2-gorcunov@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220224201841.412565-1-gorcunov@gmail.com> References: <20220224201841.412565-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH v30 1/3] 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.35.1