From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Thu, 20 Jun 2019 14:53:11 +0300 From: Vladimir Davydov Subject: Re: [tarantool-patches] [PATCH v4 2/9] core: latch_steal routine Message-ID: <20190620115311.ste2aez4rmqbmfln@esperanza> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: To: Georgy Kirichenko Cc: tarantool-patches@freelists.org List-ID: On Thu, Jun 20, 2019 at 12:23:09AM +0300, Georgy Kirichenko wrote: > Allow to steal locked latch ownership for fiber which isn't owner > of the latch. This is required to process transaction triggers > asynchronously. > > Prerequisites: #1254 > --- > src/lib/core/latch.h | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/src/lib/core/latch.h b/src/lib/core/latch.h > index 49c59cf63..580942564 100644 > --- a/src/lib/core/latch.h > +++ b/src/lib/core/latch.h > @@ -155,6 +155,16 @@ latch_trylock(struct latch *l) > return latch_lock_timeout(l, 0); > } > > +/** > + * Take a latch ownership > + */ > +static inline void > +latch_steal(struct latch *l) > +{ > + assert(l->owner != NULL); > + l->owner = fiber(); > +} > + Please try not to introduce dead code. This patch should be squashed into the one that actually uses latch_steal IMO.