forked from enlightenment/efl
ecore: Use eina locks for _ecore_lock()
Always count lock calls too. Signed-off-by: Mike McCormack <mj.mccormack@samsung.com> SVN revision: 62372
This commit is contained in:
parent
3277e6b5e0
commit
a541e19c16
|
@ -64,6 +64,8 @@ static void _thread_callback(void *data, void *buffer, unsigned int nbyte);
|
|||
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_init(void)
|
|||
_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
|
||||
|
|
|
@ -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_main_loop_shutdown(void);
|
|||
|
||||
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
|
||||
}
|
||||
|
||||
/*
|
||||
* Callback wrappers all assume that ecore _ecore_lock has been called
|
||||
|
|
|
@ -390,7 +390,6 @@ static LRWK(_ecore_thread_global_hash_lock);
|
|||
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 @@ _ecore_thread_init(void)
|
|||
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 @@ _ecore_thread_assert_main_loop_thread(const char *function)
|
|||
}
|
||||
}
|
||||
|
||||
#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,
|
||||
|
|
Loading…
Reference in New Issue