Modified to call tpl_gsource_destroy only once. 60/282360/1
authorJoonbum Ko <joonbum.ko@samsung.com>
Fri, 30 Sep 2022 07:33:54 +0000 (16:33 +0900)
committerJoonbum Ko <joonbum.ko@samsung.com>
Fri, 30 Sep 2022 07:33:57 +0000 (16:33 +0900)
 - tpl_gsource_destroy means 'sending destroy message to thread'.
  So it need not to be called in loop.

Change-Id: Ifd5706d738a2385396acaa3723138b2f564de4c2
Signed-off-by: Joonbum Ko <joonbum.ko@samsung.com>
src/tpl_wl_egl_thread.c

index 4434972..487cf63 100755 (executable)
@@ -970,8 +970,9 @@ __tpl_wl_egl_display_init(tpl_display_t *display)
 free_display:
        if (wl_egl_display->tdm.tdm_source) {
                tpl_gmutex_lock(&wl_egl_display->tdm.tdm_mutex);
+               // Send destroy mesage to thread
+               tpl_gsource_destroy(wl_egl_display->tdm.tdm_source, TPL_TRUE);
                while (!wl_egl_display->tdm.gsource_finalized) {
-                       tpl_gsource_destroy(wl_egl_display->tdm.tdm_source, TPL_TRUE);
                        tpl_gcond_wait(&wl_egl_display->tdm.tdm_cond, &wl_egl_display->tdm.tdm_mutex);
                }
                tpl_gmutex_unlock(&wl_egl_display->tdm.tdm_mutex);
@@ -979,8 +980,9 @@ free_display:
 
        if (wl_egl_display->disp_source) {
                tpl_gmutex_lock(&wl_egl_display->disp_mutex);
+               // Send destroy mesage to thread
+               tpl_gsource_destroy(wl_egl_display->disp_source, TPL_TRUE);
                while (!wl_egl_display->gsource_finalized) {
-                       tpl_gsource_destroy(wl_egl_display->disp_source, TPL_TRUE);
                        tpl_gcond_wait(&wl_egl_display->disp_cond, &wl_egl_display->disp_mutex);
                }
                tpl_gmutex_unlock(&wl_egl_display->disp_mutex);
@@ -1024,8 +1026,9 @@ __tpl_wl_egl_display_fini(tpl_display_t *display)
                         * caller should use tpl_gcond_wait() in the loop with checking finalized flag
                         * */
                        tpl_gmutex_lock(&wl_egl_display->tdm.tdm_mutex);
+                       // Send destroy mesage to thread
+                       tpl_gsource_destroy(wl_egl_display->tdm.tdm_source, TPL_TRUE);
                        while (!wl_egl_display->tdm.gsource_finalized) {
-                               tpl_gsource_destroy(wl_egl_display->tdm.tdm_source, TPL_TRUE);
                                tpl_gcond_wait(&wl_egl_display->tdm.tdm_cond, &wl_egl_display->tdm.tdm_mutex);
                        }
                        wl_egl_display->tdm.tdm_source = NULL;
@@ -1038,8 +1041,9 @@ __tpl_wl_egl_display_fini(tpl_display_t *display)
                 * caller should use tpl_gcond_wait() in the loop with checking finalized flag
                 * */
                tpl_gmutex_lock(&wl_egl_display->disp_mutex);
+               // Send destroy mesage to thread
+               tpl_gsource_destroy(wl_egl_display->disp_source, TPL_TRUE);
                while (wl_egl_display->disp_source && !wl_egl_display->gsource_finalized) {
-                       tpl_gsource_destroy(wl_egl_display->disp_source, TPL_TRUE);
                        tpl_gcond_wait(&wl_egl_display->disp_cond, &wl_egl_display->disp_mutex);
                }
                wl_egl_display->disp_source = NULL;
@@ -2200,8 +2204,9 @@ __tpl_wl_egl_surface_fini(tpl_surface_t *surface)
         * caller should use tpl_gcond_wait() in the loop with checking finalized flag
         * */
        tpl_gmutex_lock(&wl_egl_surface->surf_mutex);
+       // Send destroy mesage to thread
+       tpl_gsource_destroy(wl_egl_surface->surf_source, TPL_TRUE);
        while (wl_egl_surface->surf_source && !wl_egl_surface->gsource_finalized) {
-               tpl_gsource_destroy(wl_egl_surface->surf_source, TPL_TRUE);
                tpl_gcond_wait(&wl_egl_surface->surf_cond, &wl_egl_surface->surf_mutex);
        }
        wl_egl_surface->surf_source = NULL;