GSource order



Hi,

I am not a C expert. But I looking to the code to track bug 127480. I got the idea that when a new source is added to a context it is inserted before the other sources with the same priority. I assume the main_loop processes pending events of the different sources in the order of this list.
Because each time-out event is a new source and if each new source is inserted before the other time-out sources (and the time-outs expire in the same itteration of the mainloop) then the time-out sources are processed in opposite order than that they were added. If this is the case this explains bug 127480.

Below the code of g_source_list_add. 

http://bugzilla.gnome.org/show_bug.cgi?id=127480

Regards,
Rolf

In gmain.c line 852-877:

/* Holds context's lock
 *  */
static void
g_source_list_add (GSource      *source,
                   GMainContext *context)
{
  GSource *tmp_source, *last_source;

  last_source = NULL;
  tmp_source = context->source_list;
  while (tmp_source && tmp_source->priority <= source->priority)
    {
       last_source = tmp_source;
       tmp_source = tmp_source->next;
    }

  source->next = tmp_source;
  if (tmp_source)
     tmp_source->prev = source;

  source->prev = last_source;
  if (last_source)
    last_source->next = source;
  else
    context->source_list = source;
}



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