This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Simplify the event loop


On Sun, Sep 10, 2006 at 01:07:27PM +1200, Nick Roberts wrote:
> 
> Trying to get my head round the asynchronous event loop made me feel that the
> usual loop in event-loop.c is overly complicated.  Maybe I'm missing something
> but the patch below seems to work.  There seems to be vestigial code from
> legacy concepts that are no longer present.  In any case the value of
> event_queue.last_event isn't used anywhere in the code and the comment seems to
> reflect this:

Well, the point of saving both first and last items in a linked list
like this is to avoid this loop you added:

>       {
>         /* The event will become the new last_event. */
>   
> +       gdb_event *prev_ptr;
> + 
>         event_ptr->next_event = NULL;
> !       if (event_head == NULL)
> ! 	event_head = event_ptr;
>         else
> ! 	{
> ! 	  for (prev_ptr = event_head; prev_ptr;
> ! 	       prev_ptr = prev_ptr->next_event)
> ! 	  ;
> ! 	  prev_ptr = event_ptr;
> ! 	}
>       }

Adding at the tail suddenly requires a list walk.  Since every call to
this function passes TAIL, this seems like a bad change; let's not.
It's easy enough to keep two pointers.  Or discard the linked list
entirely and use a VEC if that's simpler.

However the code in process_event can definitely be simplified.  We
don't even need the loop.  At some point there may have been a way for
an event to say that it wasn't ready, or maybe that was planned, but
it never materialized - so the loop always exits after one iteration.
Just as well since it frees event_ptr and then would use
event_ptr->next for the loop iteration.

-- 
Daniel Jacobowitz
CodeSourcery


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]