forked from enlightenment/efl
evas: simplify waiting logic for image decoding as we do not need lock and cond with Ecore_Thread infra.
This commit is contained in:
parent
ddf1907217
commit
62d6b4072c
|
@ -164,11 +164,9 @@ EAPI Engine_Image_Entry* evas_cache_engine_image_size_set(Engine_Image_Entr
|
||||||
EAPI void evas_cache_engine_image_load_data(Engine_Image_Entry *eim);
|
EAPI void evas_cache_engine_image_load_data(Engine_Image_Entry *eim);
|
||||||
|
|
||||||
EAPI void evas_cache_image_preload_data(Image_Entry *im, const Eo *target,
|
EAPI void evas_cache_image_preload_data(Image_Entry *im, const Eo *target,
|
||||||
Evas_Engine_Thread_Task_Cb func, const void *engine_data, const void *custom_data);
|
Evas_Engine_Thread_Task_Cb func, const void *engine_data, const void *custom_data);
|
||||||
EAPI void evas_cache_image_preload_cancel(Image_Entry *im, const Eo *target);
|
EAPI void evas_cache_image_preload_cancel(Image_Entry *im, const Eo *target);
|
||||||
|
|
||||||
EAPI void evas_cache_image_wakeup(void);
|
|
||||||
|
|
||||||
EAPI int evas_cache_async_frozen_get(void);
|
EAPI int evas_cache_async_frozen_get(void);
|
||||||
EAPI void evas_cache_async_freeze(void);
|
EAPI void evas_cache_async_freeze(void);
|
||||||
EAPI void evas_cache_async_thaw(void);
|
EAPI void evas_cache_async_thaw(void);
|
||||||
|
|
|
@ -26,11 +26,8 @@ struct _Evas_Cache_Preload
|
||||||
};
|
};
|
||||||
|
|
||||||
static SLK(engine_lock);
|
static SLK(engine_lock);
|
||||||
static LK(wakeup);
|
|
||||||
static int _evas_cache_mutex_init = 0;
|
static int _evas_cache_mutex_init = 0;
|
||||||
|
|
||||||
static Eina_Condition cond_wakeup;
|
|
||||||
|
|
||||||
static const Image_Entry_Task dummy_task = { NULL, NULL, NULL };
|
static const Image_Entry_Task dummy_task = { NULL, NULL, NULL };
|
||||||
|
|
||||||
static void _evas_cache_image_entry_preload_remove(Image_Entry *ie, const Eo *target);
|
static void _evas_cache_image_entry_preload_remove(Image_Entry *ie, const Eo *target);
|
||||||
|
@ -394,11 +391,6 @@ _evas_cache_image_async_heavy(void *data)
|
||||||
}
|
}
|
||||||
SLKU(current->lock_cancel);
|
SLKU(current->lock_cancel);
|
||||||
SLKU(current->lock);
|
SLKU(current->lock);
|
||||||
|
|
||||||
LKL(wakeup);
|
|
||||||
current->flags.preload_pending = 0;
|
|
||||||
eina_condition_broadcast(&cond_wakeup);
|
|
||||||
LKU(wakeup);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -414,9 +406,7 @@ _evas_cache_image_async_end(void *data)
|
||||||
ie->flags.preload_done = ie->flags.loaded;
|
ie->flags.preload_done = ie->flags.loaded;
|
||||||
ie->flags.updated_data = 1;
|
ie->flags.updated_data = 1;
|
||||||
|
|
||||||
LKL(wakeup);
|
|
||||||
ie->flags.preload_pending = 0;
|
ie->flags.preload_pending = 0;
|
||||||
LKU(wakeup);
|
|
||||||
|
|
||||||
evas_cache_image_ref(ie);
|
evas_cache_image_ref(ie);
|
||||||
while ((tmp = ie->targets))
|
while ((tmp = ie->targets))
|
||||||
|
@ -452,9 +442,7 @@ _evas_cache_image_async_cancel(void *data)
|
||||||
ie->preload = NULL;
|
ie->preload = NULL;
|
||||||
ie->cache->pending = eina_list_remove(ie->cache->pending, ie);
|
ie->cache->pending = eina_list_remove(ie->cache->pending, ie);
|
||||||
|
|
||||||
LKL(wakeup);
|
|
||||||
ie->flags.preload_pending = 0;
|
ie->flags.preload_pending = 0;
|
||||||
LKU(wakeup);
|
|
||||||
|
|
||||||
if ((ie->flags.delete_me) || (ie->flags.dirty))
|
if ((ie->flags.delete_me) || (ie->flags.dirty))
|
||||||
{
|
{
|
||||||
|
@ -467,9 +455,7 @@ _evas_cache_image_async_cancel(void *data)
|
||||||
{
|
{
|
||||||
ie->cache->preload = eina_list_append(ie->cache->preload, ie);
|
ie->cache->preload = eina_list_append(ie->cache->preload, ie);
|
||||||
ie->flags.pending = 0;
|
ie->flags.pending = 0;
|
||||||
LKL(wakeup);
|
|
||||||
ie->flags.preload_pending = 1;
|
ie->flags.preload_pending = 1;
|
||||||
LKU(wakeup);
|
|
||||||
ie->preload = evas_preload_thread_run(_evas_cache_image_async_heavy,
|
ie->preload = evas_preload_thread_run(_evas_cache_image_async_heavy,
|
||||||
_evas_cache_image_async_end,
|
_evas_cache_image_async_end,
|
||||||
_evas_cache_image_async_cancel,
|
_evas_cache_image_async_cancel,
|
||||||
|
@ -527,9 +513,7 @@ _evas_cache_image_entry_preload_add(Image_Entry *ie, const Eo *target,
|
||||||
{
|
{
|
||||||
ie->cache->preload = eina_list_append(ie->cache->preload, ie);
|
ie->cache->preload = eina_list_append(ie->cache->preload, ie);
|
||||||
ie->flags.pending = 0;
|
ie->flags.pending = 0;
|
||||||
LKL(wakeup);
|
|
||||||
ie->flags.preload_pending = 1;
|
ie->flags.preload_pending = 1;
|
||||||
LKU(wakeup);
|
|
||||||
ie->preload = evas_preload_thread_run(_evas_cache_image_async_heavy,
|
ie->preload = evas_preload_thread_run(_evas_cache_image_async_heavy,
|
||||||
_evas_cache_image_async_end,
|
_evas_cache_image_async_end,
|
||||||
_evas_cache_image_async_cancel,
|
_evas_cache_image_async_cancel,
|
||||||
|
@ -628,8 +612,6 @@ evas_cache_image_init(const Evas_Cache_Image_Func *cb)
|
||||||
if (_evas_cache_mutex_init++ == 0)
|
if (_evas_cache_mutex_init++ == 0)
|
||||||
{
|
{
|
||||||
SLKI(engine_lock);
|
SLKI(engine_lock);
|
||||||
LKI(wakeup);
|
|
||||||
eina_condition_new(&cond_wakeup, &wakeup);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cache = calloc(1, sizeof(Evas_Cache_Image));
|
cache = calloc(1, sizeof(Evas_Cache_Image));
|
||||||
|
@ -694,14 +676,20 @@ evas_cache_image_shutdown(Evas_Cache_Image *cache)
|
||||||
/* Now wait for all pending image to die */
|
/* Now wait for all pending image to die */
|
||||||
while (cache->pending)
|
while (cache->pending)
|
||||||
{
|
{
|
||||||
|
im = eina_list_data_get(cache->pending);
|
||||||
|
evas_preload_thread_cancel(im->preload);
|
||||||
|
|
||||||
evas_async_events_process();
|
evas_async_events_process();
|
||||||
LKL(wakeup);
|
if (!evas_preload_pthread_wait(im->preload, 1.0))
|
||||||
// the lazy bum who did eain threads and converted this code
|
{
|
||||||
// didn't bother to worry about Eina_Lock being a different type
|
// We have waited long enough without reaction from that said
|
||||||
// to a pthread mutex.
|
// thread, remove it from pending list and silently continue
|
||||||
if (cache->pending) eina_condition_wait(&cond_wakeup);
|
// in the hope of an ok shutdown (but something is wrong).
|
||||||
LKU(wakeup);
|
cache->pending = eina_list_remove_list(cache->pending, cache->pending);
|
||||||
|
ERR("Could not stop decoding '%s' during shutdown.\n", im->file);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
eina_hash_free(cache->activ);
|
eina_hash_free(cache->activ);
|
||||||
eina_hash_free(cache->inactiv);
|
eina_hash_free(cache->inactiv);
|
||||||
eina_hash_free(cache->mmap_activ);
|
eina_hash_free(cache->mmap_activ);
|
||||||
|
@ -710,9 +698,7 @@ evas_cache_image_shutdown(Evas_Cache_Image *cache)
|
||||||
|
|
||||||
if (--_evas_cache_mutex_init == 0)
|
if (--_evas_cache_mutex_init == 0)
|
||||||
{
|
{
|
||||||
eina_condition_free(&cond_wakeup);
|
|
||||||
SLKD(engine_lock);
|
SLKD(engine_lock);
|
||||||
LKD(wakeup);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1276,16 +1262,11 @@ evas_cache_image_load_data(Image_Entry *im)
|
||||||
evas_async_events_process();
|
evas_async_events_process();
|
||||||
evas_preload_pthread_wait(im->preload, 0.01);
|
evas_preload_pthread_wait(im->preload, 0.01);
|
||||||
|
|
||||||
LKL(wakeup);
|
|
||||||
while (im->flags.preload_pending)
|
while (im->flags.preload_pending)
|
||||||
{
|
{
|
||||||
eina_condition_wait(&cond_wakeup);
|
|
||||||
LKU(wakeup);
|
|
||||||
evas_async_events_process();
|
evas_async_events_process();
|
||||||
evas_preload_pthread_wait(im->preload, 0.01);
|
evas_preload_pthread_wait(im->preload, 0.1);
|
||||||
LKL(wakeup);
|
|
||||||
}
|
}
|
||||||
LKU(wakeup);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((im->flags.loaded) && (!im->animated.animated)) return error;
|
if ((im->flags.loaded) && (!im->animated.animated)) return error;
|
||||||
|
@ -1543,14 +1524,3 @@ evas_cache_image_pixels(Image_Entry *im)
|
||||||
if (!im->cache) return NULL;
|
if (!im->cache) return NULL;
|
||||||
return im->cache->func.surface_pixels(im);
|
return im->cache->func.surface_pixels(im);
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI void
|
|
||||||
evas_cache_image_wakeup(void)
|
|
||||||
{
|
|
||||||
if (_evas_cache_mutex_init > 0)
|
|
||||||
{
|
|
||||||
LKL(wakeup);
|
|
||||||
eina_condition_broadcast(&cond_wakeup);
|
|
||||||
LKU(wakeup);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -244,8 +244,6 @@ evas_async_events_process(void)
|
||||||
|
|
||||||
while ((nr = _evas_async_events_process_single()) > 0) count += nr;
|
while ((nr = _evas_async_events_process_single()) > 0) count += nr;
|
||||||
|
|
||||||
evas_cache_image_wakeup();
|
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,7 +271,6 @@ evas_async_events_process_blocking(void)
|
||||||
|
|
||||||
_evas_async_events_fd_blocking_set(EINA_TRUE);
|
_evas_async_events_fd_blocking_set(EINA_TRUE);
|
||||||
ret = _evas_async_events_process_single();
|
ret = _evas_async_events_process_single();
|
||||||
evas_cache_image_wakeup(); /* FIXME: is this needed ? */
|
|
||||||
_evas_async_events_fd_blocking_set(EINA_FALSE);
|
_evas_async_events_fd_blocking_set(EINA_FALSE);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -337,8 +334,6 @@ evas_async_events_put(const void *target, Evas_Callback_Type type, void *event_i
|
||||||
}
|
}
|
||||||
else ret = EINA_TRUE;
|
else ret = EINA_TRUE;
|
||||||
|
|
||||||
evas_cache_image_wakeup();
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue