From b2ca7a96dcb49aec273d5655aee1140ea80464b3 Mon Sep 17 00:00:00 2001 From: "Carsten Haitzler (Rasterman)" Date: Fri, 28 Apr 2017 11:24:48 +0900 Subject: [PATCH] thread fence code - move elsewhere in file to avoid conflicts --- src/lib/evas/common/evas_thread_render.c | 82 +++++++++++----------- src/lib/evas/include/evas_common_private.h | 3 +- 2 files changed, 43 insertions(+), 42 deletions(-) diff --git a/src/lib/evas/common/evas_thread_render.c b/src/lib/evas/common/evas_thread_render.c index 210404227e..bbde81a657 100644 --- a/src/lib/evas/common/evas_thread_render.c +++ b/src/lib/evas/common/evas_thread_render.c @@ -18,6 +18,47 @@ static int init_count = 0; #define SHUTDOWN_TIMEOUT_CHECK (1) #define SHUTDOWN_TIMEOUT (3000) +struct fence_stuff { + Eina_Lock lock; + Eina_Condition cond; +}; + +static void +_evas_thread_queue_fence(void *data) +{ + struct fence_stuff *f; + + f = data; + + eina_lock_take(&f->lock); + eina_condition_signal(&f->cond); + eina_lock_release(&f->lock); +} + +EAPI void +evas_thread_queue_wait(void) +{ + struct fence_stuff f; + + /* No shortcuts here - if the thread queue looks empty it could just mean + * it's being processed. Need a round trip. + */ + if (!eina_lock_new(&f.lock)) return; + if (!eina_condition_new(&f.cond, &f.lock)) + { + eina_lock_free(&f.lock); + return; + } + + eina_lock_take(&f.lock); + evas_thread_queue_flush(_evas_thread_queue_fence, &f); + eina_condition_wait(&f.cond); + eina_lock_release(&f.lock); + + eina_lock_free(&f.lock); + eina_condition_free(&f.cond); +} + static Eina_Bool _shutdown_timeout(double *time, int mode, int timeout_ms) { @@ -72,47 +113,6 @@ evas_thread_queue_flush(Evas_Thread_Command_Cb cb, void *data) evas_thread_queue_append(cb, data, EINA_TRUE); } -struct fence_stuff { - Eina_Lock lock; - Eina_Condition cond; -}; - -static void -_evas_thread_queue_fence(void *data) -{ - struct fence_stuff *f; - - f = data; - - eina_lock_take(&f->lock); - eina_condition_signal(&f->cond); - eina_lock_release(&f->lock); -} - -EAPI void -evas_thread_queue_wait(void) -{ - struct fence_stuff f; - - /* No shortcuts here - if the thread queue looks empty it could just mean - * it's being processed. Need a round trip. - */ - if (!eina_lock_new(&f.lock)) return; - if (!eina_condition_new(&f.cond, &f.lock)) - { - eina_lock_free(&f.lock); - return; - } - - eina_lock_take(&f.lock); - evas_thread_queue_flush(_evas_thread_queue_fence, &f); - eina_condition_wait(&f.cond); - eina_lock_release(&f.lock); - - eina_lock_free(&f.lock); - eina_condition_free(&f.cond); -} - static void* evas_thread_worker_func(void *data EINA_UNUSED, Eina_Thread thread EINA_UNUSED) { diff --git a/src/lib/evas/include/evas_common_private.h b/src/lib/evas/include/evas_common_private.h index ceb1095b32..6a7d57c655 100644 --- a/src/lib/evas/include/evas_common_private.h +++ b/src/lib/evas/include/evas_common_private.h @@ -1320,6 +1320,8 @@ Tilebuf_Rect *evas_common_regionbuf_rects_get (Regionbuf *rb); void evas_font_dir_cache_free(void); +EAPI void evas_thread_queue_wait(void); + EAPI int evas_async_events_process_blocking(void); void evas_render_rendering_wait(Evas_Public_Data *evas); void evas_all_sync(void); @@ -1328,7 +1330,6 @@ int evas_thread_init(void); int evas_thread_shutdown(void); EAPI void evas_thread_cmd_enqueue(Evas_Thread_Command_Cb cb, void *data); EAPI void evas_thread_queue_flush(Evas_Thread_Command_Cb cb, void *data); -EAPI void evas_thread_queue_wait(void); typedef enum _Evas_Render_Mode {