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.
This commit is contained in:
Ryan Lortie 2011-08-30 13:32:58 -04:00
parent 940a728fda
commit b891b3616f

View File

@ -247,8 +247,6 @@ struct _GMainContext
gint64 time; gint64 time;
gboolean time_is_fresh; gboolean time_is_fresh;
gint64 real_time;
gboolean real_time_is_fresh;
}; };
struct _GSourceCallback struct _GSourceCallback
@ -557,7 +555,6 @@ g_main_context_new (void)
context->pending_dispatches = g_ptr_array_new (); context->pending_dispatches = g_ptr_array_new ();
context->time_is_fresh = FALSE; context->time_is_fresh = FALSE;
context->real_time_is_fresh = FALSE;
g_main_context_init_pipe (context); g_main_context_init_pipe (context);
@ -2619,7 +2616,6 @@ g_main_context_prepare (GMainContext *context,
LOCK_CONTEXT (context); LOCK_CONTEXT (context);
context->time_is_fresh = FALSE; context->time_is_fresh = FALSE;
context->real_time_is_fresh = FALSE;
if (context->in_check_or_prepare) if (context->in_check_or_prepare)
{ {
@ -2788,10 +2784,7 @@ g_main_context_query (GMainContext *context,
{ {
*timeout = context->timeout; *timeout = context->timeout;
if (*timeout != 0) if (*timeout != 0)
{ context->time_is_fresh = FALSE;
context->time_is_fresh = FALSE;
context->real_time_is_fresh = FALSE;
}
} }
UNLOCK_CONTEXT (context); UNLOCK_CONTEXT (context);
@ -3498,12 +3491,9 @@ g_main_context_remove_poll_unlocked (GMainContext *context,
* g_source_get_current_time: * g_source_get_current_time:
* @source: a #GSource * @source: a #GSource
* @timeval: #GTimeVal structure in which to store current time. * @timeval: #GTimeVal structure in which to store current time.
* *
* Gets the "current time" to be used when checking * This function ignores @source and is otherwise the same as
* this source. The advantage of calling this function over * g_get_current_time().
* 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.
* *
* Deprecated: 2.28: use g_source_get_time() instead * Deprecated: 2.28: use g_source_get_time() instead
**/ **/
@ -3511,24 +3501,7 @@ void
g_source_get_current_time (GSource *source, g_source_get_current_time (GSource *source,
GTimeVal *timeval) GTimeVal *timeval)
{ {
GMainContext *context; g_get_current_time (timeval);
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);
} }
/** /**