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 3C7D46E0CB; Thu, 30 Dec 2021 23:24:24 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 3C7D46E0CB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1640895864; 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=jWh97b19EiDBfMS1fknW5m9GvYVkjKq29g9lrK6NiygFu/ffcc5zz3LuWEaqIyC8L RLD3aATabkPCejWQDBoCYpdc587fyWKl7R6z7rrRZSUrIr13vYc5xSZYC1OLgzoJDo QKbc4ONXvpQ6Z7e9onSWhZVvUdxMn27ivhZrF3l0= 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 656306E0CB for ; Thu, 30 Dec 2021 23:24:04 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 656306E0CB Received: by mail-lj1-f174.google.com with SMTP id p7so41555366ljj.1 for ; Thu, 30 Dec 2021 12:24:04 -0800 (PST) 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=AsHwO1ylwaW9RzGLdOLNJrJuBoChZ4ntBSzi0AsCd2F+F90x6aekY1g0DoNWyQ3mEE 909A12XcHI744qiHmLBG3hRZEuRwH2eqGBew39hNGOQGEOj061rprfR7ybygYzE4+7Uh iAowAb3WL3/ZGtiz7L7NZkgc+YTqHmO/deDKRNBZIeONCiZKFAB0X3oYu99N5+gvBXio QWa/pWGEzJptQFuXMhB6V+6o4vXMslkxf5jj58bKCys+h7LiAt1lRn1GhxEDOd5wXkoH VQATtDFHBBgHG9J4axvgDfR+yfo0awzm6mGZgrIshDRPiajk4Rs1i1H8poMnMe+efz4O k/SA== X-Gm-Message-State: AOAM531r3TEay6PLcMoWOnplL4qi5xCJea9dmA3vftfp8sPQQb8MeSM6 wWLl8s4/c7x4UhdupSZJu/jo/BpRMDY= X-Google-Smtp-Source: ABdhPJymj40o5SU25oA9vE12urNp3Hys0ulI6qng5zccR6Z+e5sjbTxP/t5dleKI47CXwyysnGtvaA== X-Received: by 2002:a05:651c:12c3:: with SMTP id 3mr27141747lje.311.1640895843426; Thu, 30 Dec 2021 12:24:03 -0800 (PST) Received: from grain.localdomain ([5.18.251.97]) by smtp.gmail.com with ESMTPSA id k12sm2230091lfg.151.2021.12.30.12.24.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Dec 2021 12:24:02 -0800 (PST) Received: by grain.localdomain (Postfix, from userid 1000) id 86D015A001F; Thu, 30 Dec 2021 23:23:48 +0300 (MSK) To: tml Date: Thu, 30 Dec 2021 23:23:45 +0300 Message-Id: <20211230202347.353494-2-gorcunov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211230202347.353494-1-gorcunov@gmail.com> References: <20211230202347.353494-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH v27 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