evas: don't use EINA_LOCK_INITIALIZER and improve eina_threads call.
Only call eina_threads_shutdown when thread are dead and not before. Release and destroy thread lock before calling evas_async_events_process as you should never have a lock taken in the main loop when calling it. SVN revision: 59119
This commit is contained in:
parent
9140383045
commit
902350711d
|
@ -31,8 +31,9 @@ struct _Evas_Cache_Preload
|
|||
Image_Entry *ie;
|
||||
};
|
||||
|
||||
static LK(engine_lock) = EINA_LOCK_INITIALIZER;
|
||||
static LK(wakeup) = EINA_LOCK_INITIALIZER;
|
||||
static LK(engine_lock);
|
||||
static LK(wakeup);
|
||||
static int _evas_cache_mutex_init = 0;
|
||||
|
||||
static pthread_cond_t cond_wakeup = PTHREAD_COND_INITIALIZER;
|
||||
|
||||
|
@ -553,6 +554,12 @@ evas_cache_image_init(const Evas_Cache_Image_Func *cb)
|
|||
{
|
||||
Evas_Cache_Image *cache;
|
||||
|
||||
if (_evas_cache_mutex_init++ == 0)
|
||||
{
|
||||
LKI(engine_lock);
|
||||
LKI(wakeup);
|
||||
}
|
||||
|
||||
cache = calloc(1, sizeof(Evas_Cache_Image));
|
||||
if (!cache) return NULL;
|
||||
cache->func = *cb;
|
||||
|
@ -583,13 +590,19 @@ evas_cache_image_shutdown(Evas_Cache_Image *cache)
|
|||
LKL(cache->lock);
|
||||
#endif
|
||||
cache->references--;
|
||||
if (cache->references > 0)
|
||||
if (cache->references != 0)
|
||||
{
|
||||
#ifdef EVAS_FRAME_QUEUING
|
||||
LKU(cache->lock);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
#ifdef EVAS_FRAME_QUEUING
|
||||
/* Release and destroy lock early ! */
|
||||
LKU(cache->lock);
|
||||
LKD(cache->lock);
|
||||
#endif
|
||||
|
||||
#ifdef BUILD_ASYNC_PRELOAD
|
||||
EINA_LIST_FREE(cache->preload, im)
|
||||
{
|
||||
|
@ -638,11 +651,13 @@ evas_cache_image_shutdown(Evas_Cache_Image *cache)
|
|||
#endif
|
||||
eina_hash_free(cache->activ);
|
||||
eina_hash_free(cache->inactiv);
|
||||
#ifdef EVAS_FRAME_QUEUING
|
||||
LKU(cache->lock);
|
||||
LKD(cache->lock);
|
||||
#endif
|
||||
free(cache);
|
||||
|
||||
if (--_evas_cache_mutex_init == 0)
|
||||
{
|
||||
LKD(engine_lock);
|
||||
LKD(wakeup);
|
||||
}
|
||||
}
|
||||
|
||||
EAPI Image_Entry *
|
||||
|
|
|
@ -45,7 +45,7 @@ struct _Evas_Preload_Pthread_Data
|
|||
static int _threads_count = 0;
|
||||
static Evas_Preload_Pthread_Worker *_workers = NULL;
|
||||
|
||||
static LK(_mutex) = EINA_LOCK_INITIALIZER;
|
||||
static LK(_mutex);
|
||||
|
||||
static void
|
||||
_evas_preload_thread_end(void *data)
|
||||
|
@ -54,6 +54,8 @@ _evas_preload_thread_end(void *data)
|
|||
Evas_Preload_Pthread_Data *p = NULL;
|
||||
|
||||
if (pthread_join(pth->thread, (void **)&p) != 0) free(p);
|
||||
|
||||
eina_threads_shutdown();
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -67,7 +69,6 @@ _evas_preload_thread_done(void *target __UNUSED__, Evas_Callback_Type type __UNU
|
|||
else
|
||||
work->func_end(work->data);
|
||||
|
||||
eina_threads_shutdown();
|
||||
free(work);
|
||||
}
|
||||
|
||||
|
@ -76,7 +77,7 @@ _evas_preload_thread_worker(void *data)
|
|||
{
|
||||
Evas_Preload_Pthread_Data *pth = data;
|
||||
Evas_Preload_Pthread_Worker *work;
|
||||
|
||||
|
||||
eina_sched_prio_drop();
|
||||
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
|
||||
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
|
||||
|
@ -129,6 +130,8 @@ _evas_preload_thread_init(void)
|
|||
{
|
||||
_threads_max = eina_cpu_count();
|
||||
if (_threads_max < 1) _threads_max = 1;
|
||||
|
||||
LKI(_mutex);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -151,6 +154,8 @@ _evas_preload_thread_shutdown(void)
|
|||
free(work);
|
||||
}
|
||||
LKU(_mutex);
|
||||
|
||||
LKD(_mutex);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue