[glib/wip/glib-next: 24/27] GMainLoop: remove wall clock time cache



commit 063bc2dae390aaf9852d06096df695d7bb4be618
Author: Ryan Lortie <desrt desrt ca>
Date:   Tue Aug 30 13:32:58 2011 -0400

    GMainLoop: remove wall clock time cache
    
    Since GMainLoop is now purely monotonic, it really doesn't make sense to
    cache the wallclock time just for the sake of making a deprecated call
    more efficient.

 glib/gmain.c |   37 +++++--------------------------------
 1 files changed, 5 insertions(+), 32 deletions(-)
---
diff --git a/glib/gmain.c b/glib/gmain.c
index 324f751..929c333 100644
--- a/glib/gmain.c
+++ b/glib/gmain.c
@@ -247,8 +247,6 @@ struct _GMainContext
 
   gint64   time;
   gboolean time_is_fresh;
-  gint64   real_time;
-  gboolean real_time_is_fresh;
 };
 
 struct _GSourceCallback
@@ -557,7 +555,6 @@ g_main_context_new (void)
   context->pending_dispatches = g_ptr_array_new ();
   
   context->time_is_fresh = FALSE;
-  context->real_time_is_fresh = FALSE;
   
   g_main_context_init_pipe (context);
 
@@ -2608,7 +2605,6 @@ g_main_context_prepare (GMainContext *context,
   LOCK_CONTEXT (context);
 
   context->time_is_fresh = FALSE;
-  context->real_time_is_fresh = FALSE;
 
   if (context->in_check_or_prepare)
     {
@@ -2777,10 +2773,7 @@ g_main_context_query (GMainContext *context,
     {
       *timeout = context->timeout;
       if (*timeout != 0)
-        {
-	  context->time_is_fresh = FALSE;
-	  context->real_time_is_fresh = FALSE;
-        }
+        context->time_is_fresh = FALSE;
     }
   
   UNLOCK_CONTEXT (context);
@@ -3487,12 +3480,9 @@ g_main_context_remove_poll_unlocked (GMainContext *context,
  * g_source_get_current_time:
  * @source:  a #GSource
  * @timeval: #GTimeVal structure in which to store current time.
- * 
- * Gets the "current time" to be used when checking 
- * this source. The advantage of calling this function over
- * calling g_get_current_time() directly is that when 
- * checking multiple sources, GLib can cache a single value
- * instead of having to repeatedly get the system time.
+ *
+ * This function ignores @source and is otherwise the same as
+ * g_get_current_time().
  *
  * Deprecated: 2.28: use g_source_get_time() instead
  **/
@@ -3500,24 +3490,7 @@ void
 g_source_get_current_time (GSource  *source,
 			   GTimeVal *timeval)
 {
-  GMainContext *context;
-  
-  g_return_if_fail (source->context != NULL);
- 
-  context = source->context;
-
-  LOCK_CONTEXT (context);
-
-  if (!context->real_time_is_fresh)
-    {
-      context->real_time = g_get_real_time ();
-      context->real_time_is_fresh = TRUE;
-    }
-  
-  timeval->tv_sec = context->real_time / 1000000;
-  timeval->tv_usec = context->real_time % 1000000;
-  
-  UNLOCK_CONTEXT (context);
+  g_get_current_time (timeval);
 }
 
 /**



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]