it seems to me that if eina is not build with threading support, there is not a lot of thread safety in ecore
Vincent On Thu, 11 Aug 2011, Enlightenment SVN wrote: > Log: > ecore: Use eina locks for _ecore_lock() > > Always count lock calls too. > > Signed-off-by: Mike McCormack <mj.mccorm...@samsung.com> > > Author: mike_m > Date: 2011-08-11 22:21:49 -0700 (Thu, 11 Aug 2011) > New Revision: 62372 > Trac: http://trac.enlightenment.org/e/changeset/62372 > > Modified: > trunk/ecore/src/lib/ecore/ecore.c trunk/ecore/src/lib/ecore/ecore_private.h > trunk/ecore/src/lib/ecore/ecore_thread.c > > Modified: trunk/ecore/src/lib/ecore/ecore.c > =================================================================== > --- trunk/ecore/src/lib/ecore/ecore.c 2011-08-12 05:17:07 UTC (rev 62371) > +++ trunk/ecore/src/lib/ecore/ecore.c 2011-08-12 05:21:49 UTC (rev 62372) > @@ -64,6 +64,8 @@ > static Eina_List *_thread_cb = NULL; > static Ecore_Pipe *_thread_call = NULL; > static Eina_Lock _thread_safety; > +Eina_Lock _ecore_main_loop_lock; > +int _ecore_main_lock_count; > > /** OpenBSD does not define CODESET > * FIXME ?? > @@ -139,6 +141,7 @@ > _ecore_time_init(); > > eina_lock_new(&_thread_safety); > + eina_lock_new(&_ecore_main_loop_lock); > _thread_call = ecore_pipe_add(_thread_callback, NULL); > > #if HAVE_MALLINFO > > Modified: trunk/ecore/src/lib/ecore/ecore_private.h > =================================================================== > --- trunk/ecore/src/lib/ecore/ecore_private.h 2011-08-12 05:17:07 UTC (rev > 62371) > +++ trunk/ecore/src/lib/ecore/ecore_private.h 2011-08-12 05:21:49 UTC (rev > 62372) > @@ -1,6 +1,8 @@ > #ifndef _ECORE_PRIVATE_H > #define _ECORE_PRIVATE_H > > +#include <assert.h> > + > extern int _ecore_log_dom ; > #ifdef _ECORE_DEFAULT_LOG_DOM > # undef _ECORE_DEFAULT_LOG_DOM > @@ -199,22 +201,31 @@ > > void _ecore_throttle(void); > > -#ifdef HAVE_THREAD_SAFETY > -void _ecore_lock(void); > -void _ecore_unlock(void); > -#else > +extern int _ecore_main_lock_count; > +extern Eina_Lock _ecore_main_loop_lock; > + > static inline void > _ecore_lock(void) > { > +#ifdef HAVE_THREAD_SAFETY > + eina_lock_take(&_ecore_main_loop_lock); > +#else > /* at least check we're not being called from a thread */ > EINA_MAIN_LOOP_CHECK_RETURN; > +#endif > + _ecore_main_lock_count++; > + assert(_ecore_main_lock_count == 1); > } > > static inline void > _ecore_unlock(void) > { > + _ecore_main_lock_count--; > + assert(_ecore_main_lock_count == 0); > +#ifdef HAVE_THREAD_SAFETY > + eina_lock_release(&_ecore_main_loop_lock); > +#endif > } > -#endif > > /* > * Callback wrappers all assume that ecore _ecore_lock has been called > > Modified: trunk/ecore/src/lib/ecore/ecore_thread.c > =================================================================== > --- trunk/ecore/src/lib/ecore/ecore_thread.c 2011-08-12 05:17:07 UTC (rev > 62371) > +++ trunk/ecore/src/lib/ecore/ecore_thread.c 2011-08-12 05:21:49 UTC (rev > 62372) > @@ -390,7 +390,6 @@ > static LK(_ecore_thread_global_hash_mutex); > static CD(_ecore_thread_global_hash_cond); > > -static LK(_ecore_main_loop_mutex); > static Eina_Bool have_main_loop_thread = 0; > > static Eina_Trash *_ecore_thread_worker_trash = NULL; > @@ -794,7 +793,6 @@ > LKI(_ecore_pending_job_threads_mutex); > LRWKI(_ecore_thread_global_hash_lock); > LKI(_ecore_thread_global_hash_mutex); > - LKI(_ecore_main_loop_mutex); > CDI(_ecore_thread_global_hash_cond); > #endif > } > @@ -874,26 +872,6 @@ > } > } > > -#ifdef HAVE_THREAD_SAFETY > -static int lock_count; > - > -void > -_ecore_lock(void) > -{ > - LKL(_ecore_main_loop_mutex); > - lock_count++; > - assert(lock_count == 1); > -} > - > -void > -_ecore_unlock(void) > -{ > - lock_count--; > - assert(lock_count == 0); > - LKU(_ecore_main_loop_mutex); > -} > -#endif > - > EAPI Ecore_Thread * > ecore_thread_run(Ecore_Thread_Cb func_blocking, > Ecore_Thread_Cb func_end, > > > ------------------------------------------------------------------------------ > Get a FREE DOWNLOAD! and learn more about uberSVN rich system, > user administration capabilities and model configuration. Take > the hassle out of deploying and managing Subversion and the > tools developers use with it. > http://p.sf.net/sfu/wandisco-dev2dev > _______________________________________________ > enlightenment-svn mailing list > enlightenment-...@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/enlightenment-svn > > ------------------------------------------------------------------------------ Get a FREE DOWNLOAD! and learn more about uberSVN rich system, user administration capabilities and model configuration. Take the hassle out of deploying and managing Subversion and the tools developers use with it. http://p.sf.net/sfu/wandisco-dev2dev _______________________________________________ enlightenment-devel mailing list enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel