wl_egl: Remove Unused tpl functions in tpl_utils_gthread 75/319375/2
authorTaeHyeon Jeong <thyeon.jeong@samsung.com>
Tue, 22 Oct 2024 06:52:16 +0000 (15:52 +0900)
committerTaeHyeon Jeong <thyeon.jeong@samsung.com>
Tue, 5 Nov 2024 08:05:22 +0000 (17:05 +0900)
- tpl_gthread_continue()
- tpl_ghtread_pause_in_idle()
- tpl_gthread_wait_idle()
- _thread_idle_cb()

Change-Id: Ie54280161f493adc985a6a7a0b08aac1c5e6dce0

src/tpl_utils_gthread.c
src/tpl_utils_gthread.h

index 167e2161a9f6a2e3d1e2da41fdbb78249af71085..70675660d52af982d09c2e42accf93642f340614 100644 (file)
@@ -498,120 +498,6 @@ tpl_gcond_signal(tpl_gcond *gcond)
        g_cond_signal(gcond);
 }
 
-static gboolean
-_thread_idle_cb(gpointer data)
-{
-       tpl_gthread *gthread = (tpl_gthread *)data;
-
-       TPL_LOG_D("[WAIT_IDLE]", "THREAD IDLE CALLBACK");
-
-       g_mutex_lock(&gthread->idle_mutex);
-       gthread->is_idle = TPL_TRUE;
-       g_cond_broadcast(&gthread->idle_cond);
-       g_mutex_unlock(&gthread->idle_mutex);
-
-       /* If the caller thread of tpl_gthread_wait_idle locked the pause_mutex,
-        * thread will be paused here until unlock */
-       TPL_LOG_D("[THREAD_PAUSE]", "try to lock pause_mutex");
-       g_mutex_lock(&gthread->pause_mutex);
-       gthread->paused = TPL_FALSE;
-       g_mutex_unlock(&gthread->pause_mutex);
-       TPL_LOG_D("[THREAD_RESUME]", "thread resumes");
-
-       return G_SOURCE_REMOVE;
-}
-
-#define WAIT_IDLE_TIMEOUT 500
-
-tpl_result_t
-tpl_gthread_wait_idle(tpl_gthread *gthread)
-{
-       gint64 end_time;
-       gboolean ret = TRUE;
-       tpl_result_t res = TPL_ERROR_NONE;
-       tpl_gid_t id;
-
-       TPL_LOG_D("[WAIT_IDLE]", "BEGIN");
-
-       g_mutex_lock(&gthread->idle_mutex);
-
-       id = tpl_gthread_add_idle(gthread, (tpl_gsource_func)_thread_idle_cb, gthread);
-       if (!id) {
-               TPL_WARN("Failed to attach idle gsource.");
-       } else {
-               /* 500ms timeout */
-               end_time = g_get_monotonic_time() +
-                                       (WAIT_IDLE_TIMEOUT * G_TIME_SPAN_MILLISECOND);
-               do {
-                       ret = g_cond_wait_until(&gthread->idle_cond,
-                                                                       &gthread->idle_mutex,
-                                                                       end_time);
-                       if (!ret) {
-                               tpl_gsource_remove(gthread, id);
-                               TPL_ERR("wait_idle timeout!");
-                               res = TPL_ERROR_TIME_OUT;
-                               break;
-                       }
-               } while (!gthread->is_idle);
-       }
-
-       gthread->is_idle = TPL_FALSE;
-
-       g_mutex_unlock(&gthread->idle_mutex);
-
-       TPL_LOG_D("[WAIT_IDLE]", "END");
-
-       return res;
-}
-
-tpl_bool_t
-tpl_gthread_pause_in_idle(tpl_gthread *gthread)
-{
-       TPL_CHECK_ON_NULL_RETURN_VAL(gthread, TPL_FALSE);
-
-       tpl_result_t res;
-       int cnt = 0;
-
-       /* Assume three threads. (M, C, wl-egl-thread)
-        * C thread : already locked pause_mutex and doing their own job.
-        * M thread : call pause_in_idle and trying to lock pause_mutex.
-        * wl-egl-thread : trying to lock pause_mutex in _thread_idle_cb.
-        *
-        * When C thread calls tpl_gthread_continue and unlock pause_mutex,
-        * M thread may receive schedule and lock pause_mutex.
-        * In that case, M thread should yield to wl-egl-thread, which is
-        * paused in thread_idle_cb(). */
-       do {
-               g_mutex_lock(&gthread->pause_mutex);
-               if (gthread->paused) {
-                       g_mutex_unlock(&gthread->pause_mutex);
-                       sched_yield();
-               } else {
-                       break;
-               }
-       } while (++cnt <= 100);
-
-       res = tpl_gthread_wait_idle(gthread);
-       if (res != TPL_ERROR_NONE) {
-               TPL_ERR("Failed to wait idle. | res(%d)", res);
-               gthread->paused = TPL_FALSE;
-               g_mutex_unlock(&gthread->pause_mutex);
-       } else {
-               gthread->paused = TPL_TRUE;
-       }
-
-       return gthread->paused;
-}
-
-void
-tpl_gthread_continue(tpl_gthread *gthread)
-{
-       TPL_CHECK_ON_NULL_RETURN(gthread);
-
-       if (!gthread->paused) return;
-       g_mutex_unlock(&gthread->pause_mutex);
-}
-
 tpl_gid_t
 tpl_gthread_add_idle(tpl_gthread *gthread, tpl_gsource_func idle_cb, void *data)
 {
index 888e4a22b87fe993047d5be3511fb0b6ebbc5f8f..24e5a9bcca8ed5373af1fbe23644fbd9fc5da80c 100644 (file)
@@ -265,34 +265,6 @@ tpl_gcond_wait_until(tpl_gcond *gcond,  tpl_gmutex *gmutex, gint64 end_time);
 void
 tpl_gcond_signal(tpl_gcond *gcond);
 
-/**
- * attach idle source and waiting for idle callback
- *
- * @param gthread Pointer to tpl_gthread
- *
- * @return tpl_result_t result of wait_idle
- */
-tpl_result_t
-tpl_gthread_wait_idle(tpl_gthread *gthread);
-
-/**
- * pause thread when idle callback is called
- *
- * @param gthread Pointer to tpl_gthread
- *
- * @return TPL_TRUE if succeed to pause, TPL_FALSE otherwise.
- */
-tpl_bool_t
-tpl_gthread_pause_in_idle(tpl_gthread *gthread);
-
-/**
- * continue thread if thread was paused
- *
- * @param gthread Pointer to tpl_gthread
- */
-void
-tpl_gthread_continue(tpl_gthread *gthread);
-
 /**
  * attach new idle source with callback func
  *