From c517bb20ee6632e6425b8350fc6a7f24ad371e64 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Sun, 24 Apr 2011 20:25:34 +0000 Subject: [PATCH] evas: use eina_lock. NOTE: now when preload and ecore_thread are not running all lock are disabled inside evas. SVN revision: 58878 --- legacy/evas/src/lib/cache/evas_preload.c | 8 ++- legacy/evas/src/lib/include/evas_common.h | 61 +++-------------------- 2 files changed, 13 insertions(+), 56 deletions(-) diff --git a/legacy/evas/src/lib/cache/evas_preload.c b/legacy/evas/src/lib/cache/evas_preload.c index 1a32c800bd..2a433134da 100644 --- a/legacy/evas/src/lib/cache/evas_preload.c +++ b/legacy/evas/src/lib/cache/evas_preload.c @@ -66,6 +66,8 @@ _evas_preload_thread_done(void *target __UNUSED__, Evas_Callback_Type type __UNU } else work->func_end(work->data); + + eina_threads_shutdown(); free(work); } @@ -187,7 +189,9 @@ evas_preload_thread_run(void (*func_heavy) (void *data), /* One more thread could be created. */ pth = malloc(sizeof(Evas_Preload_Pthread_Data)); if (!pth) goto on_error; - + + eina_threads_init(); + if (pthread_create(&pth->thread, NULL, _evas_preload_thread_worker, pth) == 0) { LKL(_mutex); @@ -196,6 +200,8 @@ evas_preload_thread_run(void (*func_heavy) (void *data), return (Evas_Preload_Pthread*)work; } + eina_threads_shutdown(); + on_error: LKL(_mutex); if (_threads_count == 0) diff --git a/legacy/evas/src/lib/include/evas_common.h b/legacy/evas/src/lib/include/evas_common.h index 7fa2b97489..c0e7628301 100644 --- a/legacy/evas/src/lib/include/evas_common.h +++ b/legacy/evas/src/lib/include/evas_common.h @@ -128,62 +128,13 @@ extern EAPI int _evas_log_dom_global; #ifdef BUILD_PTHREAD -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif +#define LK(x) Eina_Lock x +#define LKI(x) eina_lock_new(&(x)) +#define LKD(x) eina_lock_free(&(x)) +#define LKL(x) eina_lock_take(&(x)) +#define LKT(x) eina_lock_take_try(&(x)) +#define LKU(x) eina_lock_release(&(x)) -# include -# include -#ifdef __linux__ -# include -# include -# include -#endif - -//#define LKDEBUG 1 - -#ifdef LKDEBUG -EAPI Eina_Bool lockdebug; -EAPI int lockmax; -#endif - -#define LK(x) pthread_mutex_t x -#ifndef EVAS_FRAME_QUEUING -# define LKI(x) pthread_mutex_init(&(x), NULL) -#else -# define LKI(x) do {pthread_mutexattr_t __attr;\ - pthread_mutexattr_init(&__attr); \ - pthread_mutexattr_settype(&__attr, PTHREAD_MUTEX_RECURSIVE); \ - pthread_mutex_init(&(x), &__attr);} while (0) -#endif -# define LKD(x) pthread_mutex_destroy(&(x)) -# ifdef LKDEBUG -# define LKL(x) \ - do { \ - if (lockdebug) { \ - struct timeval t0, t1; \ - int dt; \ - gettimeofday(&t0, NULL); \ - pthread_mutex_lock(&(x)); \ - gettimeofday(&t1, NULL); \ - dt = (t1.tv_sec - t0.tv_sec) * 1000000; \ - if (t1.tv_usec > t0.tv_usec) dt += (t1.tv_usec - t0.tv_usec); \ - else dt -= t0.tv_usec - t1.tv_usec; \ - dt /= 1000; \ - if (dt > lockmax) { \ - fprintf(stderr, "HANG %ims - %s:%i - %s()\n", \ - dt, __FILE__, __LINE__, __FUNCTION__); \ - } \ - } \ - else { \ - pthread_mutex_lock(&(x)); \ - } \ - } while (0) -# else -# define LKL(x) pthread_mutex_lock(&(x)) -# endif -# define LKT(x) pthread_mutex_trylock(&(x)) -# define LKU(x) pthread_mutex_unlock(&(x)) # define TH(x) pthread_t x # define THI(x) int x # define TH_MAX 8