ecore: Add function to check we're the main loop thread
authormike_m <mike_m@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 5 Jul 2011 11:13:20 +0000 (11:13 +0000)
committermike_m <mike_m@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 5 Jul 2011 11:13:20 +0000 (11:13 +0000)
Rearrange the the order of startup to avoid triggering
the thread checks in ecore_event_type_new().

Signed-off-by: Mike McCormack <mj.mccormack@samsung.com>
git-svn-id: http://svn.enlightenment.org/svn/e/trunk/ecore@61040 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/ecore/ecore.c
src/lib/ecore/ecore_private.h
src/lib/ecore/ecore_thread.c

index 5736035..c92c241 100644 (file)
@@ -120,8 +120,8 @@ ecore_init(void)
    if (_ecore_fps_debug) _ecore_fps_debug_init();
    _ecore_main_loop_init();
    _ecore_signal_init();
-   _ecore_exe_init();
    _ecore_thread_init();
+   _ecore_exe_init();
    _ecore_glib_init();
    _ecore_job_init();
    _ecore_time_init();
index e9643b3..34af3be 100644 (file)
@@ -185,6 +185,9 @@ void          _ecore_fps_debug_runtime_add(double t);
 
 void _ecore_thread_init(void);
 void _ecore_thread_shutdown(void);
+void _ecore_thread_assert_main_loop_thread(const char *function);
+
+#define ECORE_MAIN_LOOP_ASSERT() _ecore_thread_assert_main_loop_thread(__FUNCTION__)
 
 void _ecore_glib_init(void);
 void _ecore_glib_shutdown(void);
index c77eb49..56b7664 100644 (file)
@@ -764,6 +764,11 @@ _ecore_thread_worker_new(void)
 void
 _ecore_thread_init(void)
 {
+#ifdef EFL_HAVE_THREADS
+   main_loop_thread = PHS();
+   have_main_loop_thread = 1;
+#endif
+
    _ecore_thread_count_max = eina_cpu_count();
    if (_ecore_thread_count_max <= 0)
      _ecore_thread_count_max = 1;
@@ -773,8 +778,6 @@ _ecore_thread_init(void)
 
 #ifdef EFL_HAVE_THREADS
    del_handler = ecore_event_handler_add(ECORE_THREAD_PIPE_DEL, _ecore_thread_pipe_del, NULL);
-   main_loop_thread = PHS();
-   have_main_loop_thread = 1;
 
    LKI(_ecore_pending_job_threads_mutex);
    LRWKI(_ecore_thread_global_hash_lock);
@@ -842,6 +845,22 @@ _ecore_thread_shutdown(void)
    _ecore_thread_pipe = NULL;
 }
 
+void
+_ecore_thread_assert_main_loop_thread(const char *function)
+{
+   Eina_Bool good;
+#ifdef EFL_HAVE_THREADS
+   good = (main_loop_thread == PHS());
+#else
+   good = Eina_True;
+#endif
+   if (!good)
+     {
+        EINA_LOG_CRIT("Call to %s from wrong thread!", function);
+        abort();
+     }
+}
+
 /**
  * @addtogroup Ecore_Group Ecore - Main Loop and Job Functions.
  *