[gegl] add gegl_is_main_thread



commit d80f962d442a622c48b3628a4097b95afdedd8d2
Author: Øyvind Kolås <pippin gimp org>
Date:   Thu Apr 21 16:22:41 2016 +0100

    add gegl_is_main_thread

 gegl/gegl-init.c |   10 ++++++++++
 gegl/gegl-init.h |    2 ++
 2 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/gegl/gegl-init.c b/gegl/gegl-init.c
index fbfc545..0fcbf02 100644
--- a/gegl/gegl-init.c
+++ b/gegl/gegl-init.c
@@ -222,6 +222,13 @@ gegl_init_i18n (void)
     }
 }
 
+static GThread *main_thread = NULL;
+
+gboolean gegl_is_main_thread (void)
+{
+  return g_thread_self () == main_thread;
+}
+
 void
 gegl_init (gint    *argc,
            gchar ***argv)
@@ -233,6 +240,7 @@ gegl_init (gint    *argc,
   if (initialized)
     return;
 
+
   initialized = TRUE;
 
   context = g_option_context_new (NULL);
@@ -702,6 +710,8 @@ gegl_post_parse_hook (GOptionContext *context,
                    NULL);
   gegl_operations_set_licenses_from_string (config->application_license);
 
+  main_thread = g_thread_self ();
+
   return TRUE;
 }
 
diff --git a/gegl/gegl-init.h b/gegl/gegl-init.h
index b72519c..2f80d5a 100644
--- a/gegl/gegl-init.h
+++ b/gegl/gegl-init.h
@@ -94,6 +94,8 @@ void          gegl_load_module_directory (const gchar *path);
  */
 GeglConfig   *gegl_config                (void);
 
+gboolean gegl_is_main_thread (void);
+
 G_END_DECLS
 
 #endif /* __GEGL_INIT_H__ */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]