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 BA0776EC55; Mon, 26 Jul 2021 18:35:29 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org BA0776EC55 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1627313729; 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=uQfwow2pIew8cvKUeG/L62PbDRZtAAQUmyS5YhGiHchz08XiZ8uU8k/vcgp0DDTdI c0Eih0Kt5LDgIdaW/flyFMKaL1S4s/WP4lgEVKPS4XfRd5XO663LzXKtDy0byIysuk uYPlmkkbwwlo7L7U9Jkl3cGzNkwMo7j7J7LzrT10= Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) (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 0E72E6EC55 for ; Mon, 26 Jul 2021 18:35:08 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 0E72E6EC55 Received: by mail-lf1-f50.google.com with SMTP id z2so16268266lft.1 for ; Mon, 26 Jul 2021 08:35:08 -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=ojiS5e/FwQ4RHNreJAOT+sU9pe19Hh3U2BlASNgdyZcr5XIKkPROujc9sdQrvFyksb 2U/owwQ7PGfd8g8IcljoaDTFrAzQTcwByqmhQ882/+0xdcHVJcn4S/bZEDrlEabi8jVX ayf/PRZFoDfChC1FbL6CeJImkzHuasF7dQffnY6gvRu/KNeCubtgMeF0WqdS336JLQ+b MXzvDoJtcd9+3KBTRma78LNsTCxY1MtTN/wkyvHCPqeNqSliD46+8QrHl9h+g4F9WtjB bxSCCNbzkhnDjxhVDioj5JL5uFCkEHtXasFzwuROKWhv4ohRmuCxeT9ovS+9qbe2HIjo sNew== X-Gm-Message-State: AOAM5302IcfiCTDSZpgGtg59fcx2yXDON76P6PiyXmCL1GaVOsmkDtBz 4eM7iUkly64gZjTVxT7LeSXwjqy3pMKvzw== X-Google-Smtp-Source: ABdhPJxiEv2KZtTDbvGq/ToIumIo7w+N6l+cQz9lUugjL9ksJuah226uMyaE1+ncXVv9qWGKW2mylQ== X-Received: by 2002:ac2:5bcb:: with SMTP id u11mr13630844lfn.136.1627313707191; Mon, 26 Jul 2021 08:35:07 -0700 (PDT) Received: from grain.localdomain ([5.18.255.97]) by smtp.gmail.com with ESMTPSA id q20sm31409lfu.168.2021.07.26.08.35.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jul 2021 08:35:06 -0700 (PDT) Received: by grain.localdomain (Postfix, from userid 1000) id 2A01A5A001D; Mon, 26 Jul 2021 18:34:53 +0300 (MSK) To: tml Date: Mon, 26 Jul 2021 18:34:47 +0300 Message-Id: <20210726153452.113897-2-gorcunov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210726153452.113897-1-gorcunov@gmail.com> References: <20210726153452.113897-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH v8 1/6] 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