TPL_CHECK_ON_NULL_RETURN(gthread);
GSource *idle_source = NULL;
+ gint64 end_time;
+ gboolean ret = TRUE;
TPL_DEBUG("[WAIT IDLE] BEGIN");
g_source_attach(idle_source, g_main_loop_get_context(gthread->loop));
g_source_unref(idle_source);
+ /* 200ms timeout */
+ end_time = g_get_monotonic_time() +
+ (200 * G_TIME_SPAN_MILLISECOND);
+
while (!gthread->is_idle) {
- g_cond_wait(>hread->idle_cond, >hread->idle_mutex);
+ ret = g_cond_wait_until(>hread->idle_cond,
+ >hread->idle_mutex,
+ end_time);
+ if (!ret) {
+ TPL_ERR("wait_idle timeout!");
+ break;
+ }
}
g_mutex_unlock(>hread->idle_mutex);