mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-03 23:20:15 +01:00
glib-aux: add nm_g_main_context_iterate_for_msec() helper
This commit is contained in:
parent
17dcef41bd
commit
06713e7645
2 changed files with 32 additions and 0 deletions
|
|
@ -6548,3 +6548,33 @@ nm_utils_thread_local_register_destroy(gpointer tls_data, GDestroyNotify destroy
|
|||
entry->destroy_notify = destroy_notify;
|
||||
c_list_link_tail(lst_head, &entry->lst);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static gboolean
|
||||
_iterate_for_msec_timeout(gpointer user_data)
|
||||
{
|
||||
GSource **p_source = user_data;
|
||||
|
||||
nm_clear_g_source_inst(p_source);
|
||||
return G_SOURCE_CONTINUE;
|
||||
}
|
||||
|
||||
void
|
||||
nm_g_main_context_iterate_for_msec(GMainContext *context, guint timeout_msec)
|
||||
{
|
||||
GSource *source;
|
||||
|
||||
/* In production is this function not very useful. It is however useful to
|
||||
* have in the toolbox for printf debugging. */
|
||||
|
||||
source = g_timeout_source_new(timeout_msec);
|
||||
g_source_set_callback(source, _iterate_for_msec_timeout, &source, NULL);
|
||||
|
||||
if (!context)
|
||||
context = g_main_context_default();
|
||||
|
||||
g_source_attach(source, context);
|
||||
while (source)
|
||||
g_main_context_iteration(context, TRUE);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1901,6 +1901,8 @@ nm_g_main_context_iterate_ready(GMainContext *context)
|
|||
}
|
||||
}
|
||||
|
||||
void nm_g_main_context_iterate_for_msec(GMainContext *context, guint timeout_msec);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static inline int
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue