GMutex glue_internal_lock;
GCond loop_cond;
gint ref_count;
- gboolean thread_ready;
} glib_glue_t;
}
g_mutex_unlock(&glue->glue_internal_lock);
- g_main_context_unref(loop_ctx);
glue_unref(glue);
}
g_return_val_if_fail(glue, NULL);
GMainContext *thread_main_context = g_main_loop_get_context(glue->gml);
- /* Set up the thread's context and run it. */
- g_main_context_push_thread_default(thread_main_context);
+ /* Set up the thread’s context and run it. */
+ g_main_context_push_thread_default (thread_main_context);
- g_mutex_lock(&glue->glue_internal_lock);
- glue->thread_ready = TRUE;
- g_cond_signal(&glue->loop_cond);
- g_mutex_unlock(&glue->glue_internal_lock);
+ g_main_loop_run (glue->gml);
- g_main_loop_run(glue->gml);
- g_main_loop_unref(glue->gml);
-
- g_main_context_pop_thread_default(thread_main_context);
+ g_main_context_pop_thread_default (thread_main_context);
g_mutex_lock(&glue->glue_internal_lock);
g_cond_signal(&glue->loop_cond);
return NULL;
}
-
-static gboolean check_owner(gpointer data)
-{
- if (data != NULL)
- g_assert(data == g_thread_self());
-
- return FALSE;
-}
-
-
int mrp_mainloop_register_with_glib(mrp_mainloop_t *ml, GMainLoop *gml)
{
glib_glue_t *glue;
mrp_log_error("Thread creation failed");
return FALSE;
}
- g_mutex_lock(&glue->glue_internal_lock);
- while (!glue->thread_ready)
- g_cond_wait(&glue->loop_cond, &glue->glue_internal_lock);
- g_mutex_unlock(&glue->glue_internal_lock);
- g_main_context_invoke(loop_ctx, check_owner, glue->worker);
}
return TRUE;
}