[glib/wip/source-api: 2/5] GMainLoop: remove wall clock time cache



commit 2a1281469208e1cd91d55245427c4fd24e10ebbb
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 ab7c1c3..58d77b1 100644
--- a/glib/gmain.c
+++ b/glib/gmain.c
@@ -251,8 +251,6 @@ struct _GMainContext
 
   gint64   time;
   gboolean time_is_fresh;
-  gint64   real_time;
-  gboolean real_time_is_fresh;
 };
 
 struct _GSourceCallback
@@ -610,7 +608,6 @@ g_main_context_new (void)
   context->pending_dispatches = g_ptr_array_new ();
   
   context->time_is_fresh = FALSE;
-  context->real_time_is_fresh = FALSE;
   
 #ifdef G_THREADS_ENABLED
   if (g_thread_supported ())
@@ -2679,7 +2676,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)
     {
@@ -2852,10 +2848,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);
@@ -3588,12 +3581,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
  **/
@@ -3601,24 +3591,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]