forked from enlightenment/efl
eina: use Eina_Spinlock for Eina_Log.
This commit is contained in:
parent
1b07350a46
commit
82d86ea42d
|
@ -1,6 +1,7 @@
|
||||||
2013-10-11 Cedric Bail
|
2013-10-11 Cedric Bail
|
||||||
|
|
||||||
* Eina: add Eina_Spinlock API.
|
* Eina: add Eina_Spinlock API,
|
||||||
|
use Eina_Spinlock in Eina_Log.
|
||||||
|
|
||||||
2013-10-10 Carsten Haitzler (The Rasterman)
|
2013-10-10 Carsten Haitzler (The Rasterman)
|
||||||
|
|
||||||
|
|
1
NEWS
1
NEWS
|
@ -198,6 +198,7 @@ Improvements:
|
||||||
- Eina_Tiler now take tile size into account.
|
- Eina_Tiler now take tile size into account.
|
||||||
- Improve support for 64bits system.
|
- Improve support for 64bits system.
|
||||||
- eina_strlcat now work with a NULL source.
|
- eina_strlcat now work with a NULL source.
|
||||||
|
- Use Eina_Spinlock for eina_log.
|
||||||
* Eet:
|
* Eet:
|
||||||
- Display more information with eet -l -v.
|
- Display more information with eet -l -v.
|
||||||
- Force thread to always run during eet_cache_concurrency test.
|
- Force thread to always run during eet_cache_concurrency test.
|
||||||
|
|
|
@ -143,53 +143,11 @@ static Eina_Thread _main_thread;
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#ifdef EFL_HAVE_POSIX_THREADS_SPINLOCK
|
static Eina_Spinlock _log_mutex;
|
||||||
|
# define LOG_LOCK() if(_threads_enabled) {eina_spinlock_take(&_log_mutex); }
|
||||||
static pthread_spinlock_t _log_lock;
|
# define LOG_UNLOCK() if(_threads_enabled) {eina_spinlock_release(&_log_mutex); }
|
||||||
|
# define INIT() eina_spinlock_new(&_log_mutex)
|
||||||
static Eina_Bool _eina_log_spinlock_init(void)
|
# define SHUTDOWN() eina_spinlock_free(&_log_mutex)
|
||||||
{
|
|
||||||
if (pthread_spin_init(&_log_lock, PTHREAD_PROCESS_PRIVATE) == 0)
|
|
||||||
return EINA_TRUE;
|
|
||||||
|
|
||||||
fprintf(stderr,
|
|
||||||
"ERROR: pthread_spin_init(%p, PTHREAD_PROCESS_PRIVATE): %s\n",
|
|
||||||
&_log_lock, strerror(errno));
|
|
||||||
return EINA_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
# define LOG_LOCK() \
|
|
||||||
if (_threads_enabled) \
|
|
||||||
do { \
|
|
||||||
if (0) { \
|
|
||||||
fprintf(stderr, "+++LOG LOG_LOCKED! [%s, %lu]\n", \
|
|
||||||
__FUNCTION__, (unsigned long)eina_thread_self()); } \
|
|
||||||
if (EINA_UNLIKELY(_threads_enabled)) { \
|
|
||||||
pthread_spin_lock(&_log_lock); } \
|
|
||||||
} while (0)
|
|
||||||
# define LOG_UNLOCK() \
|
|
||||||
if (_threads_enabled) \
|
|
||||||
do { \
|
|
||||||
if (EINA_UNLIKELY(_threads_enabled)) { \
|
|
||||||
pthread_spin_unlock(&_log_lock); } \
|
|
||||||
if (0) { \
|
|
||||||
fprintf(stderr, \
|
|
||||||
"---LOG LOG_UNLOCKED! [%s, %lu]\n", \
|
|
||||||
__FUNCTION__, (unsigned long)eina_thread_self()); } \
|
|
||||||
} while (0)
|
|
||||||
# define INIT() _eina_log_spinlock_init()
|
|
||||||
# define SHUTDOWN() pthread_spin_destroy(&_log_lock)
|
|
||||||
|
|
||||||
#else /* ! EFL_HAVE_POSIX_THREADS_SPINLOCK */
|
|
||||||
|
|
||||||
static Eina_Lock _log_mutex;
|
|
||||||
# define LOG_LOCK() if(_threads_enabled) {eina_lock_take(&_log_mutex); }
|
|
||||||
# define LOG_UNLOCK() if(_threads_enabled) {eina_lock_release(&_log_mutex); }
|
|
||||||
# define INIT() eina_lock_new(&_log_mutex)
|
|
||||||
# define SHUTDOWN() eina_lock_free(&_log_mutex)
|
|
||||||
|
|
||||||
#endif /* ! EFL_HAVE_POSIX_THREADS_SPINLOCK */
|
|
||||||
|
|
||||||
|
|
||||||
// List of domains registered
|
// List of domains registered
|
||||||
static Eina_Log_Domain *_log_domains = NULL;
|
static Eina_Log_Domain *_log_domains = NULL;
|
||||||
|
|
Loading…
Reference in New Issue