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 469EF6E46D; Fri, 15 Oct 2021 00:57:03 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 469EF6E46D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1634248623; 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: From; b=jY8J7DoPymlEyQS89JNoI2LXpYKBrxVlWV3YYvsTOnjDv+AzK6t92jHIc246QFK6F XANkW2P/iSOrOyKJpfy3/8wR/xngD8yoAGVsdTYo94zDf74CR12hHgvyQzG4mHA1MS gfmNt3O64njtiIzwr8S6W6sf7RalbwxqOzTFw4gg= Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) (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 E2EDD6EC57 for ; Fri, 15 Oct 2021 00:56:37 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org E2EDD6EC57 Received: by mail-lf1-f48.google.com with SMTP id i24so31923785lfj.13 for ; Thu, 14 Oct 2021 14:56:37 -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=wwgrG/+Cb9jZLLGaY50U9gQKZI59V8eszQmvdHa/xzr2wKNn7YgGPV7Y0+VXcKWLER naqVP8npps9Vbh01yUBF74QdPT3AsYrZPn1VAIktSvgnXBOH4/6U+gdNr/A3xjpcBqCi 72Fpk7X7dad+kxsz5WEGwsiyaCByGBQqNtF/n7Sn+66IcANT0n5BVprWz//69zmBqSAo I4oVEmVh1biUVFYrnhhCu5uG6HGlqqJ3XI7XSYBJM4jm0/ZUbOjtigmMkhl6d6Yf7nH0 KiOYZa+F9JSyyX54uIYeOJp72OVynqGERFwKZ2/XhPDAgeIaFwMO+PmkEkK3nx/KdQU9 keQw== X-Gm-Message-State: AOAM530ZHw0r0xF7neqCKwhdA1nkxQQdim0w0S0zUg9gbT9kmSHZOyEe 0mbB/yjYn8TTI3pjWzplFV1XamW38GI= X-Google-Smtp-Source: ABdhPJxE7R0cO/iWKYd17/ZqQE2btikgueCrJvgmAwUJIoukNu2LvCPxGoDwFa84aL6prxVVABy34g== X-Received: by 2002:a2e:b5b7:: with SMTP id f23mr8634539ljn.382.1634248596886; Thu, 14 Oct 2021 14:56:36 -0700 (PDT) Received: from grain.localdomain ([5.18.253.97]) by smtp.gmail.com with ESMTPSA id s10sm326758lfr.172.2021.10.14.14.56.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Oct 2021 14:56:36 -0700 (PDT) Received: by grain.localdomain (Postfix, from userid 1000) id B9DCB5A001F; Fri, 15 Oct 2021 00:56:23 +0300 (MSK) To: tml Date: Fri, 15 Oct 2021 00:56:20 +0300 Message-Id: <20211014215622.49732-2-gorcunov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211014215622.49732-1-gorcunov@gmail.com> References: <20211014215622.49732-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH v23 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 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