From fd1c04bfd3bf30c7c443d365310556789aa40efb Mon Sep 17 00:00:00 2001 From: cedric Date: Fri, 29 Jul 2011 14:56:42 +0000 Subject: [PATCH] eina: add eina_main_loop_is. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/eina@61896 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- ChangeLog | 5 +++++ src/include/eina_main.h | 9 +++++++++ src/lib/eina_main.c | 13 +++++++++++++ 3 files changed, 27 insertions(+) diff --git a/ChangeLog b/ChangeLog index a049e6b..9390a8c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -118,3 +118,8 @@ 2011-07-04 Carsten Haitzler (The Rasterman) * Add eina_mmap safety handling. + +2011-07-29 Cedric Bail + + * Add eina_main_loop_is. + diff --git a/src/include/eina_main.h b/src/include/eina_main.h index c2c3ffa..e94cfc1 100644 --- a/src/include/eina_main.h +++ b/src/include/eina_main.h @@ -133,6 +133,15 @@ EAPI int eina_threads_init(void); EAPI int eina_threads_shutdown(void); /** + * @brief Check if you are calling this function from the same thread Eina was initialized or not + * + * Most EFL function are not thread safe and all the call need to happen in + * the main loop. With this call you could know if you can call an EFL + * function or not. + */ +EAPI Eina_Bool eina_main_loop_is(void); + +/** * @} */ diff --git a/src/lib/eina_main.c b/src/lib/eina_main.c index bb60c19..9a3cf42 100644 --- a/src/lib/eina_main.c +++ b/src/lib/eina_main.c @@ -316,6 +316,19 @@ eina_threads_shutdown(void) #endif } +EAPI Eina_Bool +eina_main_loop_is(void) +{ +#ifdef EINA_HAVE_DEBUG_THREADS + if (pthread_equal(_eina_main_loop, pthread_self())) + return EINA_TRUE; + return EINA_FALSE; +#else + /* FIXME: need to check how to do this on windows */ + return EINA_TRUE; +#endif +} + /** * @} */ -- 2.7.4