From: cedric Date: Fri, 29 Jul 2011 14:56:42 +0000 (+0000) Subject: eina: add eina_main_loop_is. X-Git-Tag: 2.0_alpha~64^2~27 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fd1c04bfd3bf30c7c443d365310556789aa40efb;p=framework%2Fuifw%2Feina.git 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 --- 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 +} + /** * @} */