[glib/wip/hadess/socket-test-not-parallel: 1/7] XXX Warn when a source takes too long to process
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/hadess/socket-test-not-parallel: 1/7] XXX Warn when a source takes too long to process
- Date: Thu, 21 Nov 2019 10:05:31 +0000 (UTC)
commit eb79ffd09f4680cfacbb1c9ff0adf27b434e4a61
Author: Bastien Nocera <hadess hadess net>
Date: Sat Mar 22 13:18:04 2014 +0100
XXX Warn when a source takes too long to process
glib/gmain.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
---
diff --git a/glib/gmain.c b/glib/gmain.c
index 95093e727..4e752c053 100644
--- a/glib/gmain.c
+++ b/glib/gmain.c
@@ -3143,6 +3143,8 @@ g_main_dispatch (GMainContext *context)
if (!SOURCE_DESTROYED (source))
{
+ GTimer *timer;
+ gdouble elapsed;
gboolean was_in_call;
gpointer user_data = NULL;
GSourceFunc callback = NULL;
@@ -3180,11 +3182,22 @@ g_main_dispatch (GMainContext *context)
current->source = source;
current->depth++;
+ timer = g_timer_new ();
TRACE (GLIB_MAIN_BEFORE_DISPATCH (g_source_get_name (source), source,
dispatch, callback, user_data));
need_destroy = !(* dispatch) (source, callback, user_data);
TRACE (GLIB_MAIN_AFTER_DISPATCH (g_source_get_name (source), source,
dispatch, need_destroy));
+ elapsed = g_timer_elapsed (timer, NULL);
+ g_timer_destroy (timer);
+ if (elapsed >= (1.0 / 60.0))
+ {
+ const char *name;
+ name = g_source_get_name (source);
+ if (name == NULL)
+ g_message ("Source '%p' doesn't have a name", source);
+ g_message ("Source '%s' took %0.0lf msecs", name, elapsed * 1000.0);
+ }
current->source = prev_source;
current->depth--;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]