eina: add eina_main_loop_is.

SVN revision: 61896
This commit is contained in:
Cedric BAIL 2011-07-29 14:56:42 +00:00
parent b3469dd413
commit 2b574523d2
3 changed files with 27 additions and 0 deletions

View File

@ -118,3 +118,8 @@
2011-07-04 Carsten Haitzler (The Rasterman) 2011-07-04 Carsten Haitzler (The Rasterman)
* Add eina_mmap safety handling. * Add eina_mmap safety handling.
2011-07-29 Cedric Bail
* Add eina_main_loop_is.

View File

@ -132,6 +132,15 @@ EAPI int eina_threads_init(void);
*/ */
EAPI int eina_threads_shutdown(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);
/** /**
* @} * @}
*/ */

View File

@ -316,6 +316,19 @@ eina_threads_shutdown(void)
#endif #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
}
/** /**
* @} * @}
*/ */