Variable timeouts in GLib

I need to change the GLib timeout interval during its execution. Is it possible? I took a look at the source code, and it seems possible to me, but some non-public functions are required to use GLib's internal functions. Should I override GTimeoutSource or is there a way to do this?

+6
c glib gtk
source share
1 answer

In your timeout function, you can re-add the function with a new timeout interval, and then return FALSE to remove the timeout with the old interval:

 gboolean my_timeout_function(gpointer data) { // do stuff // ... if(need_to_change_interval) { g_timeout_add(new_interval, (GSourceFunc)my_timeout_function, data); return FALSE; } return TRUE; } 
+3
source share

All Articles