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 71F786F3F2; Fri, 10 Sep 2021 18:30:46 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 71F786F3F2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1631287846; 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=tEvuzZAyG75a68ZG84cwqF1Omgi/efnhB1oWjCY6G6rWO/9CR03sMumhmGXRMQgSs otRYvLKtQeE7tRZnLut7BqLhbsLi+vfrvXglVJEiJslXmB2k6vadw5gnWIFUAa94Wx m3dAZYYGdetCfWsBpqgSUtXYJGkC2/IGn2nN8Ekw= Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com [209.85.208.170]) (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 164336E463 for ; Fri, 10 Sep 2021 18:29:52 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 164336E463 Received: by mail-lj1-f170.google.com with SMTP id h1so3783668ljl.9 for ; Fri, 10 Sep 2021 08:29:52 -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=HRHB/wJMv7SarpTzSEPo5NGoWJZ2kDL0BPHhd7Wnba4=; b=wcW5O3X7YonVIRQ0NZuoKv16FkqgNoCxU8S4lONKj/YHk+LA/bqmtqvoE1pQPSlZKD /PYaaOcrw4wqMcHR3zf82Edov0HeP99NQkTOiqQU0xnyz8GL7hfEfT1ehwQgsFAvfDBp gH4gzWcjV3hbFvF10lv4XCubah/+1PcQBO41HHYHGTYe936MLqf3Hh4mDBpM147uFbgQ BLr5qmp4Lr9oGs82bgaqIEaicgg1lxxJyMQfPcxeSvgeZeM4AvkWN36v05WXQpIz8R/y Um6OKe7+Vk93oq6vh9Xju+TmWCiWGVsy1HTue1qSmqGY1vytZnCxsPHF9ZvaVE/Yryl2 4K7Q== X-Gm-Message-State: AOAM531kEqHXqBDhbbjF7HN+V+tAErKep442yfgu84IrHXePVB49etyX CHirXA1OnJRkmdgbw4y1BIRrbXrC8HHNQg== X-Google-Smtp-Source: ABdhPJxYMgSLKx8yJO+K1E2MYZkOAhEBQBeYq6yNRoTSL0i1B1Lfwbj44e4N8DX1b+sUFZY/qDXRfA== X-Received: by 2002:a2e:8881:: with SMTP id k1mr4645671lji.443.1631287791091; Fri, 10 Sep 2021 08:29:51 -0700 (PDT) Received: from grain.localdomain ([5.18.253.97]) by smtp.gmail.com with ESMTPSA id k38sm581809lfv.128.2021.09.10.08.29.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Sep 2021 08:29:50 -0700 (PDT) Received: by grain.localdomain (Postfix, from userid 1000) id C03D85A0021; Fri, 10 Sep 2021 18:29:11 +0300 (MSK) To: tml Date: Fri, 10 Sep 2021 18:29:07 +0300 Message-Id: <20210910152910.607398-4-gorcunov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210910152910.607398-1-gorcunov@gmail.com> References: <20210910152910.607398-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH v14 3/6] 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