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 131726F867; Tue, 1 Feb 2022 00:56:32 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 131726F867 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1643666192; bh=TiqXAEgZ/gHoCAwHU+b6D0oNnHUEvl2JeVP678BfyFU=; 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=FBVFgXrD9ZmO2abPNnkYwlwr7XvQfKdY2QhOqtCV1dLevmiA1rujU3P6burt4HwJs RebTUzYavtAHe4N2bmUqDp8RsAFyPFlXVyN6TLThSUQOkRDL0PF2AIu4INnwnHfy2S E66llGnIZybgAV9E5qbZmaNcUPbJsT5DrATymaMQ= Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) (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 CFF356F867 for ; Tue, 1 Feb 2022 00:56:10 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org CFF356F867 Received: by mail-lf1-f52.google.com with SMTP id z19so29660577lfq.13 for ; Mon, 31 Jan 2022 13:56:10 -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=ebTxO5IoggTB11TyAMGASMYq14S97hutc+LrD3+8mB8=; b=qk3EYypOVv/BIn1keMLReYlDEMFdzC1nwEJpiqJIohGvFmVurutayfnCZ5UaCEDStq nWvcDlXD19OyYPJvX4AS4/C9WlZ8CO7NcHtlJQfz5Iv8HvsqvlEw4Hk1ZFFhGyUGAAzu dqSSqNts+Os6TGNi6QBY0e/0VtqdutttK7Kqi0gAB8NQMRdX+W3dxW4leE38eRTJS7/b HxjUbQ9/WIA5UmSfBCxOBhsjHRYOfHayUzwC/Nyx0Fo5Jmnoi0CVMwi1SlLara0hvwIe JPbnvPj1aILILK6YO4M2RJGFNkvOYhB2DqM43anAAbiu9LVSYRDWHqaOxFzn/n3Nw53N EhiA== X-Gm-Message-State: AOAM5332CMkGm1y8EdIWYdmBM+ANdcgvEpq7hT+rkg6nWDGjmucK5NDM NSTZ07GSnA1mCKlBSGZYmbjjASCxf90= X-Google-Smtp-Source: ABdhPJz63tE3ehtdBTXBenkRbmyB7M5IoijN/GjOVjjkNewuDzdRPR3GBWBlRUUmFRBxfvA65D1Fhw== X-Received: by 2002:a05:6512:3f91:: with SMTP id x17mr3075154lfa.402.1643666170021; Mon, 31 Jan 2022 13:56:10 -0800 (PST) Received: from grain.localdomain ([5.18.251.97]) by smtp.gmail.com with ESMTPSA id bt10sm3789911lfb.224.2022.01.31.13.56.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jan 2022 13:56:09 -0800 (PST) Received: by grain.localdomain (Postfix, from userid 1000) id 244515A001F; Tue, 1 Feb 2022 00:55:57 +0300 (MSK) To: tml Date: Tue, 1 Feb 2022 00:55:52 +0300 Message-Id: <20220131215554.1367429-2-gorcunov@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220131215554.1367429-1-gorcunov@gmail.com> References: <20220131215554.1367429-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [RFC v29 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.34.1