[CRIU] [PATCH 1/2] criu: lock -- Add completions

Andrey Vagin avagin at virtuozzo.com
Wed Apr 20 11:02:23 PDT 2016


On Wed, Apr 20, 2016 at 07:09:06PM +0300, Cyrill Gorcunov wrote:
> Suitable for one-shot actions.
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov at virtuozzo.com>
> ---
>  criu/include/lock.h | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
> 
> diff --git a/criu/include/lock.h b/criu/include/lock.h
> index 1678d10..fcc5ed8 100644
> --- a/criu/include/lock.h
> +++ b/criu/include/lock.h
> @@ -154,4 +154,26 @@ static inline void mutex_unlock(mutex_t *m)
>  	BUG_ON(sys_futex((u32 *)&m->raw.counter, FUTEX_WAKE, 1, NULL, NULL, 0) < 0);
>  }
>  
> +#define completion_t futex_t

Why is it not typedef?

> +
> +static inline void init_completion(completion_t *c)
> +{
> +	futex_init(c);
> +}
> +
> +static inline void complete(completion_t *c)
> +{
> +	futex_set_and_wake(c, 1);
> +}
> +
> +static inline void abort_completion(completion_t *c)
> +{
> +	futex_abort_and_wake(c);
> +}
> +
> +static inline void wait_for_completion(completion_t *c)
> +{
> +	futex_wait_until(c, 1);

I think we have to return wether it was compeleted of aborted
> +}
> +
>  #endif /* __CR_LOCK_H__ */
> -- 
> 2.5.5
> 


More information about the CRIU mailing list