GThread *thread;
GMainLoop *loop;
- tpl_gsource *destroy_sig_source;
-
GMutex thread_mutex;
GCond thread_cond;
tpl_gthread_func init_func;
- tpl_gthread_func deinit_func;
void *func_data;
};
return thread;
}
-static tpl_bool_t
-_tpl_gthread_fini(tpl_gsource *source, uint64_t message)
-{
- tpl_gthread *thread = (tpl_gthread *)source->data;
-
- TPL_IGNORE(message);
-
- g_mutex_lock(&thread->thread_mutex);
-
- if (thread->deinit_func)
- thread->deinit_func(thread->func_data);
-
- g_cond_signal(&thread->thread_cond);
- g_mutex_unlock(&thread->thread_mutex);
-
- return TPL_FALSE;
-}
-
-static tpl_gsource_functions thread_destroy_funcs = {
- .prepare = NULL,
- .check = NULL,
- .dispatch = _tpl_gthread_fini,
- .finalize = NULL,
-};
-
tpl_gthread *
tpl_gthread_create(const char *thread_name,
tpl_gthread_func init_func, void *func_data)
g_cond_wait(&new_thread->thread_cond,
&new_thread->thread_mutex);
- new_thread->destroy_sig_source =
- tpl_gsource_create(new_thread, new_thread, -1,
- &thread_destroy_funcs, SOURCE_TYPE_FINALIZER);
g_mutex_unlock(&new_thread->thread_mutex);
return new_thread;
}
void
-tpl_gthread_destroy(tpl_gthread *thread, tpl_gthread_func deinit_func)
+tpl_gthread_destroy(tpl_gthread *thread)
{
g_mutex_lock(&thread->thread_mutex);
- thread->deinit_func = deinit_func;
- tpl_gsource_send_message(thread->destroy_sig_source, 1);
- g_cond_wait(&thread->thread_cond, &thread->thread_mutex);
g_main_loop_quit(thread->loop);
g_thread_join(thread->thread);
thread->loop = NULL;
g_mutex_unlock(&thread->thread_mutex);
+
g_mutex_clear(&thread->thread_mutex);
g_cond_clear(&thread->thread_cond);
* all resources created in tpl_gthread_create are freed.
*
* @param thread Pointer to tpl_gthread created with tpl_gthread_create().
- * @param deinit_func Function Pointer to be called in thread destroying.
*
* @see tpl_gthread_create()
*/
void
-tpl_gthread_destroy(tpl_gthread *thread, tpl_gthread_func deinit_func);
+tpl_gthread_destroy(tpl_gthread *thread);
/**
* Create a new tpl_gsource
wl_egl_display->wl_display);
}
-
static void*
_thread_init(void *data)
{
return wl_egl_display;
}
-static void
-_thread_fini(void *data)
-{
- tpl_wl_egl_display_t *wl_egl_display = (tpl_wl_egl_display_t *)data;
-
- if (wl_egl_display->tdm_initialized)
- tpl_gsource_destroy(wl_egl_display->tdm_source, TPL_FALSE);
- if (wl_egl_display->wl_initialized)
- _thread_wl_display_fini(wl_egl_display);
-}
-
static tpl_bool_t
__thread_func_disp_prepare(tpl_gsource *gsource)
{
if (wl_egl_display->disp_source)
tpl_gsource_destroy(wl_egl_display->disp_source, TPL_TRUE);
- tpl_gthread_destroy(wl_egl_display->thread, _thread_fini);
+ tpl_gthread_destroy(wl_egl_display->thread);
}
wl_egl_display->thread = NULL;
}
if (wl_egl_display->thread) {
- tpl_gthread_destroy(wl_egl_display->thread, NULL);
+ tpl_gthread_destroy(wl_egl_display->thread);
wl_egl_display->thread = NULL;
}