int gdb_do_one_event (void) { static int event_source_head = 0; const int number_of_sources = 3; int current = 0; /* First let's see if there are any asynchronous signal handlers that are ready. These would be the result of invoking any of the signal handlers. */ if (invoke_async_signal_handlers ()) return 1; /* To level the fairness across event sources, we poll them in a round-robin fashion. */ for (current = 0; current < number_of_sources; current++) { int res; switch (event_source_head) { case 0: /* Are any timers that are ready? */ res = poll_timers (); break; case 1: /* Are there events already waiting to be collected on the monitored file descriptors? */ res = gdb_wait_for_event (0); break; case 2: /* Are there any asynchronous event handlers ready? */ res = check_async_event_handlers (); break; default: internal_error (__FILE__, __LINE__, "unexpected event_source_head %d", event_source_head); } event_source_head++; if (event_source_head == number_of_sources) event_source_head = 0; if (res > 0) return 1; } /* Block waiting for a new event. If gdb_wait_for_event returns -1, we should get out because this means that there are no event sources left. This will make the event loop stop, and the application exit. */ if (gdb_wait_for_event (1) < 0) return -1; /* If gdb_wait_for_event has returned 1, it means that one event has been handled. We break out of the loop. */ return 1; }
int gdb_do_one_event (void *data) { static int event_source_head = 0; const int number_of_sources = 3; int current = 0; /* Any events already waiting in the queue? */ if (process_event ()) return 1; /* To level the fairness across event sources, we poll them in a round-robin fashion. */ for (current = 0; current < number_of_sources; current++) { switch (event_source_head) { case 0: /* Are any timers that are ready? If so, put an event on the queue. */ poll_timers (); break; case 1: /* Are there events already waiting to be collected on the monitored file descriptors? */ gdb_wait_for_event (0); break; case 2: /* Are there any asynchronous event handlers ready? */ check_async_event_handlers (); break; } event_source_head++; if (event_source_head == number_of_sources) event_source_head = 0; } /* Handle any new events collected. */ if (process_event ()) return 1; /* Block waiting for a new event. If gdb_wait_for_event returns -1, we should get out because this means that there are no event sources left. This will make the event loop stop, and the application exit. */ if (gdb_wait_for_event (1) < 0) return -1; /* Handle any new events occurred while waiting. */ if (process_event ()) return 1; /* If gdb_wait_for_event has returned 1, it means that one event has been handled. We break out of the loop. */ return 1; }
static int gdb_do_one_event (void *data) { /* Any events already waiting in the queue? */ if (process_event ()) { return 1; } /* Are any timers that are ready? If so, put an event on the queue. */ poll_timers (); /* Wait for a new event. If gdb_wait_for_event returns -1 we should get out because this means that there are no event sources left. This will make the event loop stop, and the application exit. */ if (gdb_wait_for_event () < 0) { return -1; } /* Handle any new events occurred while waiting. */ if (process_event ()) { return 1; } /* If gdb_wait_for_event has returned 1, it means that one event has been handled. We break out of the loop. */ return 1; }