[Tarantool-patches] [RFC v5 1/5] latch: add latch_is_locked helper

Serge Petrenko sergepetrenko at tarantool.org
Thu Jul 15 14:15:11 MSK 2021



15.07.2021 00:23, Cyrill Gorcunov пишет:
> To test if latch is locked.
>
> In-scope-of #6036
>
> Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>

Thanks! LGTM.

> ---
>   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.

-- 
Serge Petrenko



More information about the Tarantool-patches mailing list