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 9FE26645E5; Wed, 3 Feb 2021 22:47:48 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 9FE26645E5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1612381668; bh=fFJOvrGLjh/l+mbaOb51aHP6EEgNF9RLMuizwqmTb8Y=; h=To:References:Date:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=ESOeClawAPWZu7iaAUwpy1F0EDuZ/XQfC6POHIXM9hxRk1oxYqE8zJ3XYPJQae/Z3 VpDSdLN0SC6e1iVuQIDDTw4egiE+JkwZu3BoVC6Gw7ZWXFuzaSwErs/3n1+sBddkRa e9wUuWXwuUyLKaCXU3lKboYyW8qNOgMMBoQ64fU0= Received: from smtp46.i.mail.ru (smtp46.i.mail.ru [94.100.177.106]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id E9A3E645E5 for ; Wed, 3 Feb 2021 22:47:47 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org E9A3E645E5 Received: by smtp46.i.mail.ru with esmtpa (envelope-from ) id 1l7O7o-0008Ay-K5; Wed, 03 Feb 2021 22:47:41 +0300 To: Cyrill Gorcunov References: <20210122132700.272816-1-gorcunov@gmail.com> <20210122132700.272816-6-gorcunov@gmail.com> <20210131221317.GB2172@grain> Message-ID: <68089c28-ef69-0573-32dc-89bf9e9467e6@tarantool.org> Date: Wed, 3 Feb 2021 20:47:39 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: <20210131221317.GB2172@grain> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD953AC099BC0052A9CD7A046B9B594DE544EF4829CAF723B1F182A05F5380850405B243B961AEA6052B91DF44AD9F5914351A3BCB5BF5833B29EE2856134D2F264 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE763424119D34F5CBFEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006378D7045943A292EC88638F802B75D45FF5571747095F342E8C7A0BC55FA0FE5FC6D4878AB786A589A6CCE04487C0D597B4D4415C2CBA45FBB389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C0C26CFBAC0749D213D2E47CDBA5A96583BD4B6F7A4D31EC0BC014FD901B82EE079FA2833FD35BB23D27C277FBC8AE2E8B9FC99A4BA45EE8B4A471835C12D1D977C4224003CC836476EB9C4185024447017B076A6E789B0E975F5C1EE8F4F765FC5DDA30A206E5BD283AA81AA40904B5D9CF19DD082D7633A078D18283394535A93AA81AA40904B5D98AA50765F7900637C41D59EA31DA6D55D81D268191BDAD3D698AB9A7B718F8C442539A7722CA490C13377AFFFEAFD26923F8577A6DFFEA7C0A4A5DF6A59F2A2D93EC92FD9297F6715571747095F342E857739F23D657EF2BD5E8D9A59859A8B677084C381D43A98D089D37D7C0E48F6C5571747095F342E857739F23D657EF2B6825BDBE14D8E7025EC15B47EAE72BACBD9CCCA9EDD067B1EDA766A37F9254B7 X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A24A6D60772A99906F8E1CD14B953EB46DC027CFFC0F7BE455355D89D7DBCDD132 X-C1DE0DAB: 0D63561A33F958A5EE85CCE836A2910D8C86DB5677F6B8513DC2F21D749482E0D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75448CF9D3A7B2C848410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D348B409C2D257583DFF163FC8CA1B9769DBC30B9004CDE3137D0D6CEAC2766ACC061F92A1151B044531D7E09C32AA3244CF0976FC14D3A2C56CBBD314A6D9D3CD005AB220A9D022EBC927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojSeaWuhK039LeqGaFLRbIQg== X-Mailru-Sender: 504CC1E875BF3E7D9BC0E5172ADA31103CEDA97E0905A8D0C589A882921A366A28DD59064C361AE907784C02288277CA03E0582D3806FB6A5317862B1921BA260ED6CFD6382C13A6112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH 5/6] txn: stop using txn_has_flag 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: Vladislav Shpilevoy via Tarantool-patches Reply-To: Vladislav Shpilevoy Cc: tml Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" On 31.01.2021 23:13, Cyrill Gorcunov wrote: > On Sat, Jan 30, 2021 at 08:17:59PM +0100, Vladislav Shpilevoy wrote: >>> --- a/src/box/txn.c >>> +++ b/src/box/txn.c >>> @@ -526,7 +526,7 @@ txn_free_or_wakeup(struct txn *txn) >>> void >>> txn_complete_fail(struct txn *txn) >>> { >>> - assert(!txn_has_flag(txn, TXN_IS_DONE)); >>> + assert(!(txn->flags & TXN_IS_DONE)); >> >> Please, use explicit != 0. We don't apply '!' operator to >> non-boolean values. The same in other places. This I can even >> find in the code style guide: >> >> https://github.com/tarantool/tarantool/wiki/Code-review-procedure#code-style > > I remember this. And used this style initially. But with this rule applied > code becomes a way more ugly. For example > > - if (!txn_has_flag(txn, TXN_CAN_YIELD)) > + if ((txn->flags & TXN_CAN_YIELD) == 0) > > In first place a person notes the "logical not" operator immediately, > and this sounds more natural than excessive five symbols at the tail of > the 'if' statement. > > Another example > > - assert(!txn_has_flag(txn, TXN_IS_DONE)); > - assert(!txn_has_flag(txn, TXN_WAIT_SYNC)); > + assert(!(txn->flags & (TXN_IS_DONE | TXN_WAIT_SYNC))); > > Which should be changed to either > > assert((txn->flags & (TXN_IS_DONE | TXN_WAIT_SYNC)) == 0); > > or back to pair > > assert((txn->flags & TXN_IS_DONE) == 0); > assert((txn->flags & TXN_WAIT_SYNC) == 0); > > which is a way more worse than it was with txn_has_flag() helper, > at least for me. > > The initial rationale for this series was (as far as I remember) to > setup several flags at once, so I think you could consider implementing > txn_set_flags() helper which would do the trick instead. Thus lets drop > this series, it doesn't make anything better without using neg operator. Another purpose of the issue was to make TXN_WAIT_SYNC a part of TXN_WAIT_ACK. Because ACK is never present without SYNC. Talking of the setting many flags at once - you still can do this, even with txn_set_flag(). Just rename txn_set_flag() to txn_set_flags(), and make the flags proper bitfields like in the first commits of this series. Then we could do txn_set_flags(TXN_WAIT_SYNC | TXN_WAIT_ACK) Although I don't know what to do with checking flags. If we add txn_has_flags(), then should it return true if all the requested flags are present, or if any of them?