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 B867C6EC55; Wed, 6 Oct 2021 23:15:57 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org B867C6EC55 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1633551357; 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=CMv6M72fhNpVBhnNFRDSRzerxzh8MzPcRQrR8oEJq7J6s03aNF7PrA/WVX5n0QdI5 ATIQXbgkt9qMxKuf4Hx3ZsDY89MPiSARIEXkTWlUVcTZt341efgKLS8jmJKCSyiJeT ugafZoxoW9UMnc5goAwC2zVIgMrBKYeiGna0FfDY= 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 06CA26EC55 for ; Wed, 6 Oct 2021 23:15:38 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 06CA26EC55 Received: by mail-lf1-f43.google.com with SMTP id t9so15040395lfd.1 for ; Wed, 06 Oct 2021 13:15:38 -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=uldWOx7z0Pj6xRIneKEEbGn4EvjNnxi9TW9YIAbIjV7WhJXJycXoVkqfIKUUYz19g4 DvjDLcx081+QD53aVSRY3Hpcr5FFwNaB5NWmdAia+tH88iv2SvpWuXnwJKbrpqSUWOxZ Vs8TY8ha+GCRlA7ecTsdPz2TmRxmp/FucoizOuqy3qg8UJuVIy7ngcnFSwMOMfumKR3W ZVs0UC62QKmDZYyeOzxIGcIGbmY3YVNPjLq40qF8E06Li2+ppv04xkcPixOEjAOGuuZB ND7BlYGPohv+Gd5Wviy1hvYPQbmE5g1MEpi7Q9CpaGwhbVzXgs2+oFXhhHEP0OTOMgKy 4veA== X-Gm-Message-State: AOAM530GiceuyPzRw2Qqre3Q+0vQDKDYU4jgCcTRe9wu2/uaHtCdPlOF uMDUGV1H3WxLVK8VYDKVDYO0Q1hU28M= X-Google-Smtp-Source: ABdhPJwBUqD00VppUSCH909ASmRr/chCdG2fzKG1R4CapbfCJoS+s7BMOV7eQj3tfuqVpeR0iUeitg== X-Received: by 2002:a2e:750e:: with SMTP id q14mr104735ljc.338.1633551336933; Wed, 06 Oct 2021 13:15:36 -0700 (PDT) Received: from grain.localdomain ([5.18.253.97]) by smtp.gmail.com with ESMTPSA id e25sm2351756lfn.82.2021.10.06.13.15.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Oct 2021 13:15:35 -0700 (PDT) Received: by grain.localdomain (Postfix, from userid 1000) id EEB2A5A001F; Wed, 6 Oct 2021 23:15:22 +0300 (MSK) To: tml Date: Wed, 6 Oct 2021 23:15:20 +0300 Message-Id: <20211006201522.335898-2-gorcunov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211006201522.335898-1-gorcunov@gmail.com> References: <20211006201522.335898-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH v20 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.31.1