[CRIU] [PATCH 1/2 v2] criu: lock -- Add completions
Cyrill Gorcunov
gorcunov at virtuozzo.com
Wed Apr 20 11:47:48 PDT 2016
On Wed, Apr 20, 2016 at 11:02:23AM -0700, Andrey Vagin wrote:
> 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>
> > ---
Update attached.
-------------- next part --------------
>From e9b974cf7b9d7e47a419d990ae6ae1dc33c36364 Mon Sep 17 00:00:00 2001
From: Cyrill Gorcunov <gorcunov at virtuozzo.com>
Date: Wed, 20 Apr 2016 18:46:38 +0300
Subject: [PATCH 1/2] criu: lock -- Add completions
Suitable for one-shot actions.
Signed-off-by: Cyrill Gorcunov <gorcunov at virtuozzo.com>
---
criu/include/lock.h | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/criu/include/lock.h b/criu/include/lock.h
index 1678d10..4f6b0f7 100644
--- a/criu/include/lock.h
+++ b/criu/include/lock.h
@@ -154,4 +154,27 @@ static inline void mutex_unlock(mutex_t *m)
BUG_ON(sys_futex((u32 *)&m->raw.counter, FUTEX_WAKE, 1, NULL, NULL, 0) < 0);
}
+typedef futex_t completion_t;
+
+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 int wait_for_completion(completion_t *c)
+{
+ futex_wait_until(c, 1);
+ return (atomic_read(&c->raw) & FUTEX_ABORT_FLAG) ? 1 : 0;
+}
+
#endif /* __CR_LOCK_H__ */
--
2.5.5
More information about the CRIU
mailing list