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 A0C226EC55; Thu, 15 Jul 2021 00:24:11 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org A0C226EC55 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1626297851; bh=NiGfM8PVynnVxt6ye9ls291XyUU3GGuDvaXaxGh7gUM=; 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=Jnmp5UCrcy31vx8AKlcZCrGq+5ZVcP/pXsRxhv7KQO4D5txUvh1TuIVzhAr1HgX9x B1ShG4T2khJo9SBuIaLTlQpbTcJsT3JXDHj8qdj5u09d/9UgsKm/AuskL1Jahn/HST EukcvbsBRQsjfU1Sh8Y307tkG94U41SI9KiQbZYg= Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) (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 E47986EC55 for ; Thu, 15 Jul 2021 00:23:48 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org E47986EC55 Received: by mail-lj1-f174.google.com with SMTP id u14so5602659ljh.0 for ; Wed, 14 Jul 2021 14:23:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HRHB/wJMv7SarpTzSEPo5NGoWJZ2kDL0BPHhd7Wnba4=; b=jzcixWDBKjBwF7opMgMGYbBjWzEpzCRgEvJQsYzAz+NOyq3rBJOYXh8yz7nMYecNfo GOe6QF7MPWDDduqu2c8ThuwbwfeTRCnBxyJ0hp+w1Vjm5XKc3D4TyXgHPCa+BsWFjMlP Hiwdpvf8IODPfq2XYBWwYXz9iuVeUEYQdn2MTPBB65U/qR5U8N7JsjYaFftSd1yqA9/c 8PkjrWTja2jqU7sBZV8TKG6HpqwlSrGK5ZsRyTXA0yqdzOPf/m6wFs1URX1ao+Ulwi3R zTjyOR7nDm6yuxOyJDwQxfwcg4Opd23O/kBIFgxvtiUV47vfZEE2Oci1dLu00pX/AzPa yL4A== X-Gm-Message-State: AOAM531opYVt6hlV1raMaN2mocgRTGHtnMtEIzIECqwl6quz96i7sOfP sMFGAtD7Bt81ceC8WaWEyTPgK+TBH0S6MQ== X-Google-Smtp-Source: ABdhPJydFsfDXnfcBnEPS+DJf9ZikK+ufZAG+PxyFJO3+8s8oKHhuSNoQAghKQDrQBefj+jdsW9oTg== X-Received: by 2002:a05:651c:1507:: with SMTP id e7mr10797069ljf.9.1626297827895; Wed, 14 Jul 2021 14:23:47 -0700 (PDT) Received: from grain.localdomain ([5.18.199.94]) by smtp.gmail.com with ESMTPSA id u7sm370779lja.58.2021.07.14.14.23.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jul 2021 14:23:46 -0700 (PDT) Received: by grain.localdomain (Postfix, from userid 1000) id 8A4825A001D; Thu, 15 Jul 2021 00:23:32 +0300 (MSK) To: tml Date: Thu, 15 Jul 2021 00:23:24 +0300 Message-Id: <20210714212328.701280-2-gorcunov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210714212328.701280-1-gorcunov@gmail.com> References: <20210714212328.701280-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [RFC v5 1/5] 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. In-scope-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