How to invoke a function in main loop context
By Yogesh Manav
17 Jul 2017 01:14
#include <glib.h>
/*this function shall be invoked in main loop context*/
gboolean _main_loop_context_callback(void *cb_data)
{
//return TRUE; //main loop idle source will be invoked multiple times
//return FALSE; //main loop idle source will be invoked just once.
}
/*This function may be executing in any subthread context*/
/*g_idle_add_full will execute the _main_loop_context_callback function in main loop context*/
int thread1(void* user_data)
{
// .. .....
g_idle_add_full(G_PRIORITY_DEFAULT, _main_loop_context_callback, cb_data, NULL);
}
You must log in to use this service. Log in now?
The tag you entered already exists.
Do you want to report this post as spam?
The post has been reported as spam.
cannot be empty.
Are you sure you want to cancel and return to the list?
The code has been copied to the clipboard.
Enter a title.
Enter a description.