[tarantool-patches] [PATCH v4 2/9] core: latch_steal routine

Vladimir Davydov vdavydov.dev at gmail.com
Thu Jun 20 14:53:11 MSK 2019


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.



More information about the Tarantool-patches mailing list