From: Joonbum Ko Date: Wed, 27 Jan 2021 03:44:03 +0000 (+0900) Subject: Fix some build problems of utils_gthread X-Git-Tag: submit/tizen/20210316.021228~29 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ddf6af3b048eb3dc64b7c7e43bb5db9bf5b905fa;p=platform%2Fcore%2Fuifw%2Flibtpl-egl.git Fix some build problems of utils_gthread Change-Id: I3c7e46a2196286664f4284c466b943cbf8ed1ba7 Signed-off-by: Joonbum Ko --- diff --git a/src/tpl_utils_gthread.c b/src/tpl_utils_gthread.c index 8bfcb01..b1480c1 100644 --- a/src/tpl_utils_gthread.c +++ b/src/tpl_utils_gthread.c @@ -34,7 +34,7 @@ struct _tpl_gsource { static gpointer _tpl_gthread_init(gpointer data) { - tpl_gthread *thread = data; + tpl_gthread *thread = (tpl_gthread *)data; g_mutex_lock(&thread->thread_mutex); @@ -44,15 +44,17 @@ _tpl_gthread_init(gpointer data) g_cond_signal(&thread->thread_cond); g_mutex_unlock(&thread->thread_mutex); - g_main_loop_run(thread->twe_loop); + g_main_loop_run(thread->loop); return thread; } -static void -_tpl_gthread_fini(gpointer data) +static tpl_bool_t +_tpl_gthread_fini(tpl_gsource *source, uint64_t message) { - tpl_gthread *thread = data; + tpl_gthread *thread = (tpl_gthread *)source->data; + + TPL_IGNORE(message); g_mutex_lock(&thread->thread_mutex); @@ -60,7 +62,9 @@ _tpl_gthread_fini(gpointer data) thread->deinit_func(thread->func_data); g_cond_signal(&thread->thread_cond); - g_mutex_unlock(&thread->thread_mutex); + g_mutex_unlock(&thread->thread_mutex); + + return TPL_FALSE; } static tpl_gsource_functions thread_destroy_funcs = { @@ -107,7 +111,7 @@ tpl_gthread_create(const char *thread_name, g_mutex_lock(&new_thread->thread_mutex); new_thread->destroy_sig_source = tpl_gsource_create(new_thread, new_thread, -1, - &thread_destroy_funcs, TPL_TRUE); + &thread_destroy_funcs, SOURCE_TYPE_FINALIZER); new_thread->loop = loop; new_thread->init_func = init_func; @@ -133,11 +137,14 @@ tpl_gthread_destroy(tpl_gthread *thread, tpl_gthread_func deinit_func) g_thread_join(thread->thread); g_main_loop_unref(thread->loop); + thread->loop = NULL; + g_mutex_unlock(&thread->thread_mutex); g_mutex_clear(&thread->thread_mutex); g_cond_clear(&thread->thread_cond); - thread->func = NULL; + thread->func_data = NULL; + thread->thread = NULL; free(thread); thread = NULL; @@ -179,7 +186,7 @@ static gboolean _thread_source_dispatch(GSource *source, GSourceFunc cb, gpointer data) { tpl_gsource *gsource = (tpl_gsource *)source; - tpl_bool_t ret = TPL_GSOURCE_CONTINUE; + gboolean ret = G_SOURCE_CONTINUE; GIOCondition cond = g_source_query_unix_fd(source, gsource->tag); TPL_IGNORE(cb); @@ -209,7 +216,7 @@ _thread_source_dispatch(GSource *source, GSourceFunc cb, gpointer data) g_source_unref(&del_source->gsource); g_cond_signal(&del_source->thread->thread_cond); - g_mutex_unlock(&del_source->thread_mutex); + g_mutex_unlock(&del_source->thread->thread_mutex); } } } else { @@ -224,7 +231,7 @@ _thread_source_dispatch(GSource *source, GSourceFunc cb, gpointer data) g_source_remove_unix_fd(&gsource->gsource, gsource->tag); g_source_destroy(&gsource->gsource); g_source_unref(&gsource->gsource); - ret = TPL_GSOURCE_REMOVE; + ret = G_SOURCE_REMOVE; } return ret; @@ -359,8 +366,12 @@ tpl_gsource_send_message(tpl_gsource *source, uint64_t message) void * tpl_gsource_get_data(tpl_gsource *source) { - if (source && source->data) - return source->data; + void *data = NULL; + + if (source) + data = source->data; + + return data; } tpl_bool_t @@ -373,7 +384,7 @@ tpl_gsource_check_io_condition(tpl_gsource *source) return TPL_FALSE; } - cond = g_source_query_unix_fd(source->gsource, source->tag); + cond = g_source_query_unix_fd(&source->gsource, source->tag); if (cond & G_IO_IN) return TPL_TRUE; diff --git a/src/tpl_utils_gthread.h b/src/tpl_utils_gthread.h index a30b86f..ee30b05 100644 --- a/src/tpl_utils_gthread.h +++ b/src/tpl_utils_gthread.h @@ -11,9 +11,6 @@ typedef struct _tpl_gthread tpl_gthread; typedef struct _tpl_gsource tpl_gsource; typedef struct _tpl_gsource_functions tpl_gsource_functions; -typedef TPL_TRUE TPL_GSOURCE_CONTINUE; -typedef TPL_FALSE TPL_GSOURCE_REMOVE; - typedef void (*tpl_gthread_func) (void *user_data); typedef GMutex tpl_gmutex; @@ -48,7 +45,7 @@ struct _tpl_gsource_functions { */ tpl_gthread * tpl_gthread_create(const char *thread_name, - tpl_gthread_init_func init_func, void *func_data); + tpl_gthread_func init_func, void *func_data); /** * Stop thread and Destroy tpl_gthread