mirror of
				https://gitlab.gnome.org/GNOME/glib.git
				synced 2025-11-03 17:48:56 +01:00 
			
		
		
		
	GMainContext: store real time as int64
This commit is contained in:
		
							
								
								
									
										19
									
								
								glib/gmain.c
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								glib/gmain.c
									
									
									
									
									
								
							@@ -266,8 +266,8 @@ struct _GMainContext
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  gint64   time;
 | 
					  gint64   time;
 | 
				
			||||||
  gboolean time_is_fresh;
 | 
					  gboolean time_is_fresh;
 | 
				
			||||||
  GTimeVal current_time;
 | 
					  gint64   real_time;
 | 
				
			||||||
  gboolean current_time_is_fresh;
 | 
					  gboolean real_time_is_fresh;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct _GSourceCallback
 | 
					struct _GSourceCallback
 | 
				
			||||||
@@ -609,7 +609,7 @@ 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->current_time_is_fresh = FALSE;
 | 
					  context->real_time_is_fresh = FALSE;
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
#ifdef G_THREADS_ENABLED
 | 
					#ifdef G_THREADS_ENABLED
 | 
				
			||||||
  if (g_thread_supported ())
 | 
					  if (g_thread_supported ())
 | 
				
			||||||
@@ -2516,7 +2516,7 @@ g_main_context_prepare (GMainContext *context,
 | 
				
			|||||||
  LOCK_CONTEXT (context);
 | 
					  LOCK_CONTEXT (context);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  context->time_is_fresh = FALSE;
 | 
					  context->time_is_fresh = FALSE;
 | 
				
			||||||
  context->current_time_is_fresh = FALSE;
 | 
					  context->real_time_is_fresh = FALSE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (context->in_check_or_prepare)
 | 
					  if (context->in_check_or_prepare)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
@@ -2682,7 +2682,7 @@ g_main_context_query (GMainContext *context,
 | 
				
			|||||||
      if (*timeout != 0)
 | 
					      if (*timeout != 0)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
	  context->time_is_fresh = FALSE;
 | 
						  context->time_is_fresh = FALSE;
 | 
				
			||||||
	  context->current_time_is_fresh = FALSE;
 | 
						  context->real_time_is_fresh = FALSE;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
@@ -3421,13 +3421,14 @@ g_source_get_current_time (GSource  *source,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  LOCK_CONTEXT (context);
 | 
					  LOCK_CONTEXT (context);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (!context->current_time_is_fresh)
 | 
					  if (!context->real_time_is_fresh)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      g_get_current_time (&context->current_time);
 | 
					      context->real_time = g_get_real_time ();
 | 
				
			||||||
      context->current_time_is_fresh = TRUE;
 | 
					      context->real_time_is_fresh = TRUE;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  *timeval = context->current_time;
 | 
					  timeval->tv_sec = context->real_time / 1000000;
 | 
				
			||||||
 | 
					  timeval->tv_usec = context->real_time % 1000000;
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  UNLOCK_CONTEXT (context);
 | 
					  UNLOCK_CONTEXT (context);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user