From f7ec79e13efacbcd32d54513877ffd3c5766442d Mon Sep 17 00:00:00 2001 From: Mike McCormack Date: Tue, 5 Jul 2011 11:13:20 +0000 Subject: [PATCH] ecore: Add function to check we're the main loop thread Rearrange the the order of startup to avoid triggering the thread checks in ecore_event_type_new(). Signed-off-by: Mike McCormack SVN revision: 61040 --- legacy/ecore/src/lib/ecore/ecore.c | 2 +- legacy/ecore/src/lib/ecore/ecore_private.h | 3 +++ legacy/ecore/src/lib/ecore/ecore_thread.c | 23 ++++++++++++++++++++-- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/legacy/ecore/src/lib/ecore/ecore.c b/legacy/ecore/src/lib/ecore/ecore.c index 5736035344..c92c2410a0 100644 --- a/legacy/ecore/src/lib/ecore/ecore.c +++ b/legacy/ecore/src/lib/ecore/ecore.c @@ -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(); diff --git a/legacy/ecore/src/lib/ecore/ecore_private.h b/legacy/ecore/src/lib/ecore/ecore_private.h index e9643b3fd9..34af3bed64 100644 --- a/legacy/ecore/src/lib/ecore/ecore_private.h +++ b/legacy/ecore/src/lib/ecore/ecore_private.h @@ -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); diff --git a/legacy/ecore/src/lib/ecore/ecore_thread.c b/legacy/ecore/src/lib/ecore/ecore_thread.c index c77eb493b5..56b7664939 100644 --- a/legacy/ecore/src/lib/ecore/ecore_thread.c +++ b/legacy/ecore/src/lib/ecore/ecore_thread.c @@ -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. *