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 93BA16EC55; Fri, 30 Jul 2021 14:36:15 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 93BA16EC55 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1627644975; 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=K0/7HffgR97W/QUoEA2cGSBWhbEElJ6dchVyhjSiA/Z0kO+bDqUuVi2s6LkAURoMO ov51686tLRWDi9nstk6u7iO8CzxFCmbW4siDTisOv+CNaobKdY9UkhBCIVg7Ph3dUd nridLEadLPYzQbHr0XZHOmzwZgnAimjRCJfixruk= Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com [209.85.208.170]) (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 B9AD86EC55 for ; Fri, 30 Jul 2021 14:35:55 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org B9AD86EC55 Received: by mail-lj1-f170.google.com with SMTP id x7so11895644ljn.10 for ; Fri, 30 Jul 2021 04:35:55 -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=Vg0Gv3uxMVIl6eK4Ylsxc6/xPw5/PlQcc8JEysB5CVwsGYGBUP/H6PvIINcFTLPq5w as6pVqEQsRomBpZp2HMAdUooCFKAkzQhNjapj42cCR5OJ7EVC41ENRoYarkJvQ8mMHB1 SRCUEhGtH3wdhG07vvTOIQWij6yTA/nDQZ/vfpIkswdIxFuywc+BlNMV00ylM8DgRYuR 9QjIIcgvKgE8+luBNZZYppx2J8lHMJ0h8vTTAN4MjbxGPFbasJj/PnP+MZeEQtUHoPUH THM6bvC1+/B5GMYKazO+A7J/nUYMeIMDtnEgbQ22zSjawoyk0jHxSYs8bm9Ynva3VLkc mf0A== X-Gm-Message-State: AOAM53037Bno0xY0RNDO2xkyEJyur8CMEUth8UNVMLHQ6BWPq0mEPrfC D3AkO3RcKgd01OowG3JEFbmXHRGkPN2w7g== X-Google-Smtp-Source: ABdhPJxSvcj71sXttlOYdH53L0OIRpqnPaAFqWrY3sDFJ9eGmQMxKp4xSK/AtKSniYBsiEvOdu9U/Q== X-Received: by 2002:a2e:8e26:: with SMTP id r6mr1409797ljk.159.1627644954741; Fri, 30 Jul 2021 04:35:54 -0700 (PDT) Received: from grain.localdomain ([5.18.255.97]) by smtp.gmail.com with ESMTPSA id g17sm83530ljm.28.2021.07.30.04.35.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Jul 2021 04:35:53 -0700 (PDT) Received: by grain.localdomain (Postfix, from userid 1000) id 33C335A001D; Fri, 30 Jul 2021 14:35:41 +0300 (MSK) To: tml Date: Fri, 30 Jul 2021 14:35:35 +0300 Message-Id: <20210730113539.563318-2-gorcunov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210730113539.563318-1-gorcunov@gmail.com> References: <20210730113539.563318-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH v9 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