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 E726F6DB08; Thu, 30 Sep 2021 12:45:22 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org E726F6DB08 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1632995123; 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=bXOSQ5SXZeF0BMA1/escjYelaaBqo3/vPk48jQPIQ6hy+VlPmsn73SX9V2CN3t7WX RM8PGEQJDuNc2MRqkJHVkrrW0ENBcuNTezuSguAozUSwUFQ+/N4bvHzLpe1kcpP+Xs iiXAQX9op5izpfJ+VunQJ7DGx4gcRiiuyVgKvHoM= Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) (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 D60816DB08 for ; Thu, 30 Sep 2021 12:45:01 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org D60816DB08 Received: by mail-lf1-f53.google.com with SMTP id i19so19808186lfu.0 for ; Thu, 30 Sep 2021 02:45:01 -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=eghNfb5d1ORF/+gAoMczC/Pz4MSvJx3xB98iaO0qW88O+Q9URPrhXXqIwKTbsPkXN3 d/k6ufJUw7yiIxRjrOTOZB1Yqs4bkob/yUy8xLsB0fyhaR//dyjKmKHW8gOiXYADGA/C N3CsHOBhHcepiTHxBeS4ch9EkRLB7P41qKcLgSTlrdPYSTgm0/F20eyHU3Rj8ksyvEg4 gQ3IPvOhq/2T99lgoEzWR3m8pGaDGEczeh6AAwD8JRDXI4fi5W0+tIjMXp9Ru8QNWzrs swC531WhKgCcS4//RSprLGEiYtZxaMDAHxLwxmRzRQULvfRyo6UFpdjmVAk8eZCIJYrH SXaA== X-Gm-Message-State: AOAM532lqBzBj840Z+eZe1aXs3ipTiBcuoghTXJ2YFYiElzR0DwZqHqn 3kL3VMr2fLg5lueQghscOENR+1b9489vRg== X-Google-Smtp-Source: ABdhPJy2MYCJuHwjq0m9dp4+s4LUO5nGF/Ja61CmjB2YxOYnYas+jmkXTWu3Bf2nck2Rc6E13L/AWA== X-Received: by 2002:a2e:3518:: with SMTP id z24mr4921268ljz.312.1632995100806; Thu, 30 Sep 2021 02:45:00 -0700 (PDT) Received: from grain.localdomain ([5.18.253.97]) by smtp.gmail.com with ESMTPSA id o12sm309484lft.254.2021.09.30.02.44.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Sep 2021 02:44:59 -0700 (PDT) Received: by grain.localdomain (Postfix, from userid 1000) id 64E2C5A001D; Thu, 30 Sep 2021 12:44:46 +0300 (MSK) To: tml Date: Thu, 30 Sep 2021 12:44:43 +0300 Message-Id: <20210930094445.316694-2-gorcunov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210930094445.316694-1-gorcunov@gmail.com> References: <20210930094445.316694-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH v19 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