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 <mj.mccormack@samsung.com>

SVN revision: 61040
This commit is contained in:
Mike McCormack 2011-07-05 11:13:20 +00:00 committed by Mike McCormack
parent 95b6992006
commit f7ec79e13e
3 changed files with 25 additions and 3 deletions

View 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();

View 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);

View 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.
*