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 988046EC55; Fri, 8 Oct 2021 20:58:47 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 988046EC55 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1633715927; 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=b9f7+MEbpqT3uHXHFvJailWP09FE2VT9huaxU9mAU7hvlnEahF23uUOweb1wHdBM1 XcjAx22nHRV/Ahd0z1F4U+YLwmwbZqpLfDsJDEWhUCxeGNWHLLT98Y9KY/5GLeNc9F 1y4MjC2pEfTkI3+hhB3lVTAs6CyNdbb6Yg1scb9I= Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) (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 048426EC55 for ; Fri, 8 Oct 2021 20:58:28 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 048426EC55 Received: by mail-lf1-f45.google.com with SMTP id x27so42626637lfu.5 for ; Fri, 08 Oct 2021 10:58:28 -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=Aqn6SapwvZdPZgUciELS4b/a+ecXZwWmZbEHPgJ4WdlBNp6ajjWZCoRfhX06LYviAu Q4AoTwAguhlDcxWe0H1dNSME84OYOA0zrrk/8xeTuZyEvOueKcsB1CpUKsw8HNKQT+x5 ZcydkOC8RKmgcN+5WESxAhjXIMrnakeYO45bXItk/nFMdJztjMnxNcwPoHH817aTwa+T v9Q89Sb0kA4ew9gIW8lHi9WGSPpn0AQz7B8d5+EWhIpeZ0wj/gA2DfmLR77vLaMfhy1B ON2WSexN64ekmTbNK9/A/3psrAstKc+ErfVO64R4Ri9KHHID3UumOUE4CkuK0Wwk9BFD aGzw== X-Gm-Message-State: AOAM530Oh944lATD8/hnISZ43r70RgC6UuMTznS+EwIl9LE98G1i2P3p 2bxjFGr8A1dr/X/JY4Kurx1Q1SXWGNQ= X-Google-Smtp-Source: ABdhPJyi6B3miD0ZdIrVjRIv/1UM85LmyUt4YvGaRxWGFskjglvjybXf4eVjN/2TjhAX2xABt+2iaA== X-Received: by 2002:a05:6512:3046:: with SMTP id b6mr11794811lfb.650.1633715907022; Fri, 08 Oct 2021 10:58:27 -0700 (PDT) Received: from grain.localdomain ([5.18.253.97]) by smtp.gmail.com with ESMTPSA id b7sm296608lfi.221.2021.10.08.10.58.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Oct 2021 10:58:26 -0700 (PDT) Received: by grain.localdomain (Postfix, from userid 1000) id 1F6FE5A001F; Fri, 8 Oct 2021 20:58:13 +0300 (MSK) To: tml Date: Fri, 8 Oct 2021 20:58:07 +0300 Message-Id: <20211008175809.349501-2-gorcunov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211008175809.349501-1-gorcunov@gmail.com> References: <20211008175809.349501-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH v21 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