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 B7CC870358; Wed, 15 Sep 2021 17:51:22 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org B7CC870358 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1631717482; 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=p+zj1ptpfvO25J53xeMM2zMhZie73FI3Qp7dAqOy71AbnIiQZVlafNoK/Vhzrjyzw ixGS+mcsxoVy8mkcmJMWIn4XWX5eJygbDl7AwdZJFMsVCq2oN+p5Qn/lqScVd4MEDB fgWYIIo76ycFiox5UYHvQ9Xz9BgFjUvrulDWnhdY= 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 3E39470358 for ; Wed, 15 Sep 2021 17:51:03 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 3E39470358 Received: by mail-lj1-f174.google.com with SMTP id i28so1548203ljm.7 for ; Wed, 15 Sep 2021 07:51:03 -0700 (PDT) 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=HRHB/wJMv7SarpTzSEPo5NGoWJZ2kDL0BPHhd7Wnba4=; b=E30jCoGXm8bmrpWjHh4dKxTAgyQnaLQX93R2q9Jk5QlcwEITPB40l57f0/ynIT/5nd IXONnr0gl/Xpjr8Syr9VICvUeztDJM8ZZoYPy9EJaJokVmOSzNBjU8Vou6dtTbg4WUz0 QswY+RwQ0Ug86zV6ZySDpLudtV5L3bPPG2nLepgv/4Q/67Ryh8o2ENlVSawLhLrwef35 bwwzrSz3PnBWMZTgS/Nt4SkZTA5SbLWUVgPGA5MccKIrOQmQVambQFBDixZYArIWJfxK Bqs6M3fx5V9u3AK7NG6T7PDzw8ZO6LiQUkcNReZK6Zoc8oz1tjuM67s2uCLpTyIkDGjc D2tA== X-Gm-Message-State: AOAM532Mk1U+pIn83k2BNNCs2zgRHB8LHxeRRFHldLzC7OcKInsG4Qtl 396sctWgsT9xfXLxZ/IL75w7HEyF+s0= X-Google-Smtp-Source: ABdhPJxUVNpRSluRh/PonaAARp7NgAufKogeC0l74dlOH8OBxvJK68xAu5pSGMXmwfBBqJlDXRqUew== X-Received: by 2002:a2e:750b:: with SMTP id q11mr302458ljc.172.1631717462240; Wed, 15 Sep 2021 07:51:02 -0700 (PDT) Received: from grain.localdomain ([5.18.253.97]) by smtp.gmail.com with ESMTPSA id f25sm6216lfk.11.2021.09.15.07.51.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Sep 2021 07:51:01 -0700 (PDT) Received: by grain.localdomain (Postfix, from userid 1000) id E2F2B5A001D; Wed, 15 Sep 2021 17:50:48 +0300 (MSK) To: tml Date: Wed, 15 Sep 2021 17:50:44 +0300 Message-Id: <20210915145046.133303-2-gorcunov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210915145046.133303-1-gorcunov@gmail.com> References: <20210915145046.133303-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH v16 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. 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