[Tarantool-patches] [PATCH v30 1/3] latch: add latch_is_locked helper

Serge Petrenko sergepetrenko at tarantool.org
Mon Feb 28 11:13:29 MSK 2022



24.02.2022 23:18, Cyrill Gorcunov пишет:
> To test if latch is locked.
>
> Part-of #6036
>
> Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
> ---
>   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.

Thanks! LGTM.

-- 
Serge Petrenko



More information about the Tarantool-patches mailing list