g_mutex_lock(>hread->idle_mutex);
gthread->is_idle = TPL_TRUE;
- g_cond_signal(>hread->idle_cond);
+ g_cond_broadcast(>hread->idle_cond);
g_mutex_unlock(>hread->idle_mutex);
/* If the caller thread of tpl_gthread_wait_idle locked the pause_mutex,
TPL_DEBUG("[WAIT IDLE] BEGIN");
g_mutex_lock(>hread->idle_mutex);
- gthread->is_idle = TPL_FALSE;
+ if (gthread->is_idle) {
+ g_mutex_unlock(>hread->idle_mutex);
+ return;
+ }
idle_source = g_idle_source_new();
if (idle_source == NULL) {
/* 200ms timeout */
end_time = g_get_monotonic_time() +
(200 * G_TIME_SPAN_MILLISECOND);
-
- while (!gthread->is_idle) {
+ do {
ret = g_cond_wait_until(>hread->idle_cond,
>hread->idle_mutex,
end_time);
TPL_ERR("wait_idle timeout!");
break;
}
- }
+ } while (!gthread->is_idle);
+
+ gthread->is_idle = TPL_FALSE;
+
g_mutex_unlock(>hread->idle_mutex);
TPL_DEBUG("[WAIT IDLE] END");