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 9364E7030F; Fri, 22 Jan 2021 16:27:39 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 9364E7030F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1611322059; bh=wbTS8ZtI+v8iXVn1/gWXfvDUzt2kz1xi/fYXkF5kO+4=; 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=GKznnDHTdK8SMvl3ivmb3in8ZP58dxbPw78ZZgmLqFY2ACfYCePDprC8QYKfpjV27 Iiu+rcutdPUaEE5+YKqiSmwYAJUgKjh5FJXsu0U4g/uWYtR5eOZ6epQiFZCEOWZDry LpwjCdfyrdhZM63ClnZtcle48XGJR6zCIOVWkfek= Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) (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 A87417030F for ; Fri, 22 Jan 2021 16:27:19 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org A87417030F Received: by mail-lf1-f53.google.com with SMTP id a8so7506553lfi.8 for ; Fri, 22 Jan 2021 05:27:19 -0800 (PST) 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=ff6QtA1U753ayoRRtLsMxwtsPR9+yl1VzFwI5QK9+Ok=; b=FhAQ9bzrwbFf9t6JGXwOddpw3s/1lfoTsKajczYgS5MT2ktg5vekgSEmAW8fJWjUkj VKuaBPF951NSKBOzrAimOsZ9SLleWT1zqDJ8OF6vLj1t5JbVIAHSPaYyfSfSr6hnWJzF sEOEs2WKoLkZphtdgs/Ub8FivInfHS5AnfHDY9cBuyWZpr2t20ciXoFP0NbplucgbU1d 7vJFXi2Qc0+M1vivSoumnQ2JEBy9rwq5FwLoH5g5GaZcYMAAHaK7CB7CFFAB8Xe8lWGc tinVtUNDSgUTv1lDYovfAyvI1Ie2pHOof8WgPCzb6YC6VenjYeHP1qD/Go3Ffg+6Xdph fmJA== X-Gm-Message-State: AOAM530cDQxVsdW3gVDiRuj+nEZY8YiUhQBLrjSYyPUB9jTOQCyafdbI qLIsNCcCaVWN5u1TYkXOI9fAhoJdKqg= X-Google-Smtp-Source: ABdhPJzbmFOnsYbeShbfo7UFUNuY2wM57dp2i5kioYe3vLAme/6diCUDWVgpHgJ9mXS2DlsyYiw/uQ== X-Received: by 2002:a05:6512:2111:: with SMTP id q17mr240637lfr.114.1611322038579; Fri, 22 Jan 2021 05:27:18 -0800 (PST) Received: from grain.localdomain ([5.18.91.94]) by smtp.gmail.com with ESMTPSA id y20sm963470lji.86.2021.01.22.05.27.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 05:27:17 -0800 (PST) Received: by grain.localdomain (Postfix, from userid 1000) id 9AE31560113; Fri, 22 Jan 2021 16:27:04 +0300 (MSK) To: tml Date: Fri, 22 Jan 2021 16:26:55 +0300 Message-Id: <20210122132700.272816-2-gorcunov@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210122132700.272816-1-gorcunov@gmail.com> References: <20210122132700.272816-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 1/6] txn: convert flags to explicit bitfield 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" Instead of shifting flags inside txn_x_flag() helpers lets define precompiled value. Moreover we're about to drop this helpers completely: better operate with bitfield directly which allows to test/set/clear a set of bits at once instead of one by one. Part-of #5128 Signed-off-by: Cyrill Gorcunov --- src/box/txn.h | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/box/txn.h b/src/box/txn.h index fca9bc1d0..b42249b17 100644 --- a/src/box/txn.h +++ b/src/box/txn.h @@ -56,25 +56,25 @@ struct Vdbe; enum txn_flag { /** Transaction has been processed. */ - TXN_IS_DONE, + TXN_IS_DONE = 0x1, /** * Transaction has been aborted by fiber yield so * should be rolled back at commit. */ - TXN_IS_ABORTED_BY_YIELD, + TXN_IS_ABORTED_BY_YIELD = 0x2, /** * fiber_yield() is allowed inside the transaction. * See txn_can_yield() for more details. */ - TXN_CAN_YIELD, + TXN_CAN_YIELD = 0x4, /** on_commit and/or on_rollback list is not empty. */ - TXN_HAS_TRIGGERS, + TXN_HAS_TRIGGERS = 0x8, /** * Synchronous transaction touched sync spaces, or an * asynchronous transaction blocked by a sync one until it * is confirmed. */ - TXN_WAIT_SYNC, + TXN_WAIT_SYNC = 0x10, /** * Synchronous transaction 'waiting for ACKs' state before * commit. In this state it waits until it is replicated @@ -82,14 +82,14 @@ enum txn_flag { * commit and returns success to a user. * TXN_WAIT_SYNC is always set, if TXN_WAIT_ACK is set. */ - TXN_WAIT_ACK, + TXN_WAIT_ACK = 0x20, /** * A transaction may be forced to be asynchronous, not * wait for any ACKs, and not depend on prepending sync * transactions. This happens in a few special cases. For * example, when applier receives snapshot from master. */ - TXN_FORCE_ASYNC, + TXN_FORCE_ASYNC = 0x40, }; enum { @@ -394,21 +394,21 @@ struct txn { }; static inline bool -txn_has_flag(struct txn *txn, enum txn_flag flag) +txn_has_flag(struct txn *txn, unsigned int flag) { - return (txn->flags & (1 << flag)) != 0; + return (txn->flags & flag) != 0; } static inline void -txn_set_flag(struct txn *txn, enum txn_flag flag) +txn_set_flag(struct txn *txn, unsigned int flag) { - txn->flags |= 1 << flag; + txn->flags |= flag; } static inline void -txn_clear_flag(struct txn *txn, enum txn_flag flag) +txn_clear_flag(struct txn *txn, unsigned int flag) { - txn->flags &= ~(1 << flag); + txn->flags &= ~flag; } /* Pointer to the current transaction (if any) */ -- 2.29.2