[Spice-devel] [PATCH spice-gtk 2/4] coroutine: replace IN_MAIN_CONTEXT macro

Marc-André Lureau marcandre.lureau at gmail.com
Tue Nov 19 07:14:23 PST 2013


Use a nicer function, with correct prefix.
Remove extra "context" from function name
---
 gtk/coroutine.h           | 8 +++++---
 gtk/coroutine_gthread.c   | 2 +-
 gtk/coroutine_ucontext.c  | 2 +-
 gtk/coroutine_winfibers.c | 2 +-
 gtk/gio-coroutine.c       | 2 +-
 gtk/spice-channel-priv.h  | 2 +-
 spice-common              | 2 +-
 7 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/gtk/coroutine.h b/gtk/coroutine.h
index 8d6c406..c7e3069 100644
--- a/gtk/coroutine.h
+++ b/gtk/coroutine.h
@@ -55,8 +55,6 @@ struct coroutine
 #endif
 };
 
-#define IN_MAIN_CONTEXT (coroutine_self() == NULL || coroutine_is_main_context(coroutine_self()))
-
 int coroutine_init(struct coroutine *co);
 
 int coroutine_release(struct coroutine *co);
@@ -69,7 +67,11 @@ void *coroutine_yieldto(struct coroutine *to, void *arg);
 
 void *coroutine_yield(void *arg);
 
-gboolean coroutine_is_main_context(struct coroutine *co);
+gboolean coroutine_is_main(struct coroutine *co);
+
+static inline gboolean coroutine_self_is_main(void) {
+	return coroutine_self() == NULL || coroutine_is_main(coroutine_self());
+}
 
 #endif
 /*
diff --git a/gtk/coroutine_gthread.c b/gtk/coroutine_gthread.c
index ab30631..3542a82 100644
--- a/gtk/coroutine_gthread.c
+++ b/gtk/coroutine_gthread.c
@@ -160,7 +160,7 @@ void *coroutine_yield(void *arg)
 	return coroutine_swap(coroutine_self(), to, arg);
 }
 
-gboolean coroutine_is_main_context(struct coroutine *co)
+gboolean coroutine_is_main(struct coroutine *co)
 {
     return (co == &leader);
 }
diff --git a/gtk/coroutine_ucontext.c b/gtk/coroutine_ucontext.c
index 4689166..6ee3695 100644
--- a/gtk/coroutine_ucontext.c
+++ b/gtk/coroutine_ucontext.c
@@ -145,7 +145,7 @@ void *coroutine_yield(void *arg)
 	return coroutine_swap(coroutine_self(), to, arg);
 }
 
-gboolean coroutine_is_main_context(struct coroutine *co)
+gboolean coroutine_is_main(struct coroutine *co)
 {
     return (co == &leader);
 }
diff --git a/gtk/coroutine_winfibers.c b/gtk/coroutine_winfibers.c
index 266b1de..bdecea6 100644
--- a/gtk/coroutine_winfibers.c
+++ b/gtk/coroutine_winfibers.c
@@ -112,7 +112,7 @@ void *coroutine_yield(void *arg)
 	return coroutine_swap(coroutine_self(), to, arg);
 }
 
-gboolean coroutine_is_main_context(struct coroutine *co)
+gboolean coroutine_is_main(struct coroutine *co)
 {
     return (co == &leader);
 }
diff --git a/gtk/gio-coroutine.c b/gtk/gio-coroutine.c
index dd2b9fc..9de9b54 100644
--- a/gtk/gio-coroutine.c
+++ b/gtk/gio-coroutine.c
@@ -252,7 +252,7 @@ void g_object_notify_main_context(GObject *object,
 {
     struct signal_data data;
 
-    if (IN_MAIN_CONTEXT) {
+    if (coroutine_self_is_main()) {
         g_object_notify(object, property_name);
     } else {
 
diff --git a/gtk/spice-channel-priv.h b/gtk/spice-channel-priv.h
index 351126f..0816061 100644
--- a/gtk/spice-channel-priv.h
+++ b/gtk/spice-channel-priv.h
@@ -186,7 +186,7 @@ void spice_caps_set(GArray *caps, guint32 cap, const gchar *desc);
 /* coroutine context */
 #define emit_main_context(object, event, args...)                                      \
     G_STMT_START {                                                                     \
-        if (IN_MAIN_CONTEXT) {                                                         \
+        if (coroutine_self_is_main()) {                                 \
             do_emit_main_context(G_OBJECT(object), event, &((struct event) { args })); \
         } else {                                                                       \
             g_signal_emit_main_context(G_OBJECT(object), do_emit_main_context,         \
diff --git a/spice-common b/spice-common
index 1450bb4..5dfdd0c 160000
--- a/spice-common
+++ b/spice-common
@@ -1 +1 @@
-Subproject commit 1450bb4ddbd8ceab9192e4f84606aa5ae54c5ea6
+Subproject commit 5dfdd0c0d5174d1d833d4830e898dcd354cf07cf
-- 
1.8.3.1



More information about the Spice-devel mailing list