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 186F46E454; Fri, 4 Mar 2022 09:01:42 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 186F46E454 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1646373702; bh=3b4TecZrx5sAa5CuqDDsyqla5UDJ8aYfj3cxATvN3NU=; 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=lmc0VMtYbjLL1jbSRYRvpuMCLTUwkOpbrUfpfOb1aGOTi46VHanTXZDYVVYPEX94g YxYnazLU5PAz0WeyYXtMMm+39kfiumSUUPsSsyvesaNfUR4ff1qIrwvYN4sB4d+UOV L7WI/cGr5ePP+32bYECBOOLDpOtYiqjoWWNNTSSQ= Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (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 4AE3B6E454 for ; Fri, 4 Mar 2022 09:01:21 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 4AE3B6E454 Received: by mail-lf1-f49.google.com with SMTP id b11so12326237lfb.12 for ; Thu, 03 Mar 2022 22:01:21 -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=xkVdqfS8mc8QRGDxd9VhWvQD3rA3Z6o4EqbFMWJRc+g=; b=iSKGovKIjO8wsloXE7vxEUyPyZMPU1DSndLx77NS/WOrxMcZWJ8YFolo7HIyMOJyp3 BBHx84LkVhjur5NLVlYzUKUTPZmgQkvbBOiU9FZJeYL2QLNx+nCvsXXwWYknTIotVcpJ EdU/p/R/D7Vmj8XQkY6HZZNxE6D+NaTTdPtvuwVEvKM9Uuk0D+hwlN6fbVVpNAzynlfV nqDzd8h62cRXQLIpjrEiac+TuHSqF10h/unqSNHk2WOtV9tCTSM/vN1gCqjoPZLnwq/Z 5T5bPV+Qy9FIUcDSG6H2Nv1dpAO77L2l92feVLb6Cke3/EsDEC+m9WBoShqG7Oh240ye JqDw== X-Gm-Message-State: AOAM531WOwz4FKpz1dqBLdf1boD+jm+ZEYVCCtMRpY+OPImzPvlCOBWd xZbhLKvbZeE/OwxHv8ZEni71910dnNc= X-Google-Smtp-Source: ABdhPJyQB+QIUtumEDOtizRmdJl4mw9PZHwicn/OL6LzDW1iVgI3IxvhCg8vXGLKIGdMXok6GsRlSw== X-Received: by 2002:a05:6512:1096:b0:443:9258:1d48 with SMTP id j22-20020a056512109600b0044392581d48mr23454922lfg.681.1646373680195; Thu, 03 Mar 2022 22:01:20 -0800 (PST) Received: from grain.localdomain ([5.18.251.97]) by smtp.gmail.com with ESMTPSA id l21-20020a056512111500b0044331532869sm842644lfg.8.2022.03.03.22.01.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 22:01:19 -0800 (PST) Received: by grain.localdomain (Postfix, from userid 1000) id B76B15A001F; Fri, 4 Mar 2022 09:01:06 +0300 (MSK) To: tml Date: Fri, 4 Mar 2022 09:01:04 +0300 Message-Id: <20220304060105.1186867-2-gorcunov@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220304060105.1186867-1-gorcunov@gmail.com> References: <20220304060105.1186867-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH v32 1/2] 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 NO_DOC=Internal helper for next patch NO_CHANGELOG=Internal helper for next patch Acked-by: Serge Petrenko 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.35.1