Delete unnecessary parameter of tpl_gthread_destroy 86/254786/1
authorJoonbum Ko <joonbum.ko@samsung.com>
Fri, 5 Feb 2021 05:28:17 +0000 (14:28 +0900)
committerJoonbum Ko <joonbum.ko@samsung.com>
Tue, 9 Mar 2021 08:52:12 +0000 (17:52 +0900)
Change-Id: I1e7871e7a101daf0bc0d3fa0ddd7e4b847433752
Signed-off-by: Joonbum Ko <joonbum.ko@samsung.com>
src/tpl_utils_gthread.c
src/tpl_utils_gthread.h
src/tpl_wl_egl.c

index 23e28d5..95a1665 100644 (file)
@@ -4,13 +4,10 @@ struct _tpl_gthread {
        GThread               *thread;
        GMainLoop             *loop;
 
-       tpl_gsource           *destroy_sig_source;
-
        GMutex                 thread_mutex;
        GCond                  thread_cond;
 
        tpl_gthread_func       init_func;
-       tpl_gthread_func       deinit_func;
        void                  *func_data;
 };
 
@@ -49,31 +46,6 @@ _tpl_gthread_init(gpointer data)
        return thread;
 }
 
-static tpl_bool_t
-_tpl_gthread_fini(tpl_gsource *source, uint64_t message)
-{
-       tpl_gthread *thread = (tpl_gthread *)source->data;
-
-       TPL_IGNORE(message);
-
-       g_mutex_lock(&thread->thread_mutex);
-
-       if (thread->deinit_func)
-               thread->deinit_func(thread->func_data);
-
-       g_cond_signal(&thread->thread_cond);
-       g_mutex_unlock(&thread->thread_mutex);
-
-       return TPL_FALSE;
-}
-
-static tpl_gsource_functions thread_destroy_funcs = {
-       .prepare  = NULL,
-       .check    = NULL,
-       .dispatch = _tpl_gthread_fini,
-       .finalize = NULL,
-};
-
 tpl_gthread *
 tpl_gthread_create(const char *thread_name,
                                   tpl_gthread_func init_func, void *func_data)
@@ -119,21 +91,15 @@ tpl_gthread_create(const char *thread_name,
        g_cond_wait(&new_thread->thread_cond,
                                &new_thread->thread_mutex);
 
-       new_thread->destroy_sig_source =
-       tpl_gsource_create(new_thread, new_thread, -1,
-                                          &thread_destroy_funcs, SOURCE_TYPE_FINALIZER);
        g_mutex_unlock(&new_thread->thread_mutex);
 
        return new_thread;
 }
 
 void
-tpl_gthread_destroy(tpl_gthread *thread, tpl_gthread_func deinit_func)
+tpl_gthread_destroy(tpl_gthread *thread)
 {
        g_mutex_lock(&thread->thread_mutex);
-       thread->deinit_func = deinit_func;
-       tpl_gsource_send_message(thread->destroy_sig_source, 1);
-       g_cond_wait(&thread->thread_cond, &thread->thread_mutex);
 
        g_main_loop_quit(thread->loop);
        g_thread_join(thread->thread);
@@ -142,6 +108,7 @@ tpl_gthread_destroy(tpl_gthread *thread, tpl_gthread_func deinit_func)
        thread->loop = NULL;
 
        g_mutex_unlock(&thread->thread_mutex);
+
        g_mutex_clear(&thread->thread_mutex);
        g_cond_clear(&thread->thread_cond);
 
index ee30b05..8c0d066 100644 (file)
@@ -54,12 +54,11 @@ tpl_gthread_create(const char *thread_name,
  * all resources created in tpl_gthread_create are freed.
  *
  * @param thread Pointer to tpl_gthread created with tpl_gthread_create().
- * @param deinit_func Function Pointer to be called in thread destroying.
  *
  * @see tpl_gthread_create()
  */
 void
-tpl_gthread_destroy(tpl_gthread *thread, tpl_gthread_func deinit_func);
+tpl_gthread_destroy(tpl_gthread *thread);
 
 /**
  * Create a new tpl_gsource
index 4e9549a..2abe646 100644 (file)
@@ -589,7 +589,6 @@ _thread_wl_display_fini(tpl_wl_egl_display_t *wl_egl_display)
                          wl_egl_display->wl_display);
 }
 
-
 static void*
 _thread_init(void *data)
 {
@@ -607,17 +606,6 @@ _thread_init(void *data)
        return wl_egl_display;
 }
 
-static void
-_thread_fini(void *data)
-{
-       tpl_wl_egl_display_t *wl_egl_display = (tpl_wl_egl_display_t *)data;
-
-       if (wl_egl_display->tdm_initialized)
-               tpl_gsource_destroy(wl_egl_display->tdm_source, TPL_FALSE);
-       if (wl_egl_display->wl_initialized)
-               _thread_wl_display_fini(wl_egl_display);
-}
-
 static tpl_bool_t
 __thread_func_disp_prepare(tpl_gsource *gsource)
 {
@@ -838,7 +826,7 @@ free_display:
                if (wl_egl_display->disp_source)
                        tpl_gsource_destroy(wl_egl_display->disp_source, TPL_TRUE);
 
-               tpl_gthread_destroy(wl_egl_display->thread, _thread_fini);
+               tpl_gthread_destroy(wl_egl_display->thread);
        }
 
        wl_egl_display->thread = NULL;
@@ -874,7 +862,7 @@ __tpl_wl_egl_display_fini(tpl_display_t *display)
                }
 
                if (wl_egl_display->thread) {
-                       tpl_gthread_destroy(wl_egl_display->thread, NULL);
+                       tpl_gthread_destroy(wl_egl_display->thread);
                        wl_egl_display->thread = NULL;
                }