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 AE7BA6E224; Wed, 2 Mar 2022 23:27:51 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org AE7BA6E224 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1646252871; 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=Wb61Isl8apTOzyvx/H/B29PmtFNym4S4M0WUfh94zjUq/3nLoo59HxSy6wVtXw7Mz SZ33+BrNQ5jYFPYQ9fo1n5EVO/2gk+RnLETxZZXsNCz9CUyydXGyyr6skmEqcJO1QG ODkG9vo98qF+X9q4qw1NY0FYxEBdVHWUF4yzVs1k= Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.171]) (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 94F656E454 for ; Wed, 2 Mar 2022 23:27:26 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 94F656E454 Received: by mail-lj1-f171.google.com with SMTP id s25so3949633lji.5 for ; Wed, 02 Mar 2022 12:27:26 -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=MucgGICYJ/iQ8Ryn6Ff8ZgvudGitt/3SxQ7OTYtQc6/NrYQWWUSplUWQ+3lG9TR6Un Wrrj/GEYHgLBIf2MKe/njLDbpwGUFedzRCaHRsgCPSIGFmToWg5wQBulbhqb3vJv6jGn Pu7xpI1K3dmzvXt4zVg01nosTymPe59Gh6n00gsrw9PfXE7aAP+jYJUTD5Z7dAmIodcT pFDtPBrcqwbYp0L1aot40xsNbF4XIpwIvoAPwF47s68tqWDQ1D/N3G3KHciX3oGRskoD mF81L+ll2O2XiRjmK8WyPN8ovSKDNdTriMZIbhnlvfTdxAbxzOV42Y8myozU6Wit2vbO +hmQ== X-Gm-Message-State: AOAM533zoYjGspb/k1VgLogKUAnbd/mL4QV+wFKRi/U88d5vjZJjPsmU bZSI+z/4ZWZy+7XfY1XtoAnWVPBa6Xnw2w== X-Google-Smtp-Source: ABdhPJzhusktX5urmjHROuklTJAdSV/TcwV8IDmt28LOuzSYHuOtR4tsc5BvpqkhFl4M+OYicbQOJw== X-Received: by 2002:a2e:b16a:0:b0:244:e31c:ea96 with SMTP id a10-20020a2eb16a000000b00244e31cea96mr22155602ljm.500.1646252845519; Wed, 02 Mar 2022 12:27:25 -0800 (PST) Received: from grain.localdomain ([5.18.251.97]) by smtp.gmail.com with ESMTPSA id h18-20020a05651c125200b0024607ecedfdsm2830030ljh.128.2022.03.02.12.27.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 12:27:24 -0800 (PST) Received: by grain.localdomain (Postfix, from userid 1000) id 5CAB35A001F; Wed, 2 Mar 2022 23:27:12 +0300 (MSK) To: tml Date: Wed, 2 Mar 2022 23:27:09 +0300 Message-Id: <20220302202711.1003906-2-gorcunov@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220302202711.1003906-1-gorcunov@gmail.com> References: <20220302202711.1003906-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH v31 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