-/* Create a generic event, to be enqueued in the event queue for
- processing. PROC is the procedure associated to the event. DATA
- is passed to PROC upon PROC invocation. */
-
-static gdb_event *
-create_event (event_handler_func proc, event_data data)
-{
- gdb_event *event;
-
- event = xmalloc (sizeof (*event));
- event->proc = proc;
- event->data = data;
-
- return event;
-}
-
-/* Create a file event, to be enqueued in the event queue for
- processing. The procedure associated to this event is always
- handle_file_event, which will in turn invoke the one that was
- associated to FD when it was registered with the event loop. */
-static gdb_event *
-create_file_event (int fd)
-{
- event_data data;
-
- data.integer = fd;
- return create_event (handle_file_event, data);
-}
-
-
-/* Free EVENT. */
-
-static void
-gdb_event_xfree (struct gdb_event *event)
-{
- xfree (event);
-}
-
-/* Initialize the event queue. */
-
-void
-initialize_event_loop (void)
-{
- event_queue = QUEUE_alloc (gdb_event_p, gdb_event_xfree);
-}
-
-/* Process one event.
- The event can be the next one to be serviced in the event queue,
- or an asynchronous event handler can be invoked in response to
- the reception of a signal.
- If an event was processed (either way), 1 is returned otherwise
- 0 is returned.
- Scan the queue from head to tail, processing therefore the high
- priority events first, by invoking the associated event handler
- procedure. */
-static int
-process_event (void)
-{
- /* First let's see if there are any asynchronous event handlers that
- are ready. These would be the result of invoking any of the
- signal handlers. */
-
- if (invoke_async_signal_handlers ())
- return 1;
-
- /* Look in the event queue to find an event that is ready
- to be processed. */
-
- if (!QUEUE_is_empty (gdb_event_p, event_queue))
- {
- /* Let's get rid of the event from the event queue. We need to
- do this now because while processing the event, the proc
- function could end up calling 'error' and therefore jump out
- to the caller of this function, gdb_do_one_event. In that
- case, we would have on the event queue an event wich has been
- processed, but not deleted. */
- gdb_event *event_ptr = QUEUE_deque (gdb_event_p, event_queue);
- /* Call the handler for the event. */
- event_handler_func *proc = event_ptr->proc;
- event_data data = event_ptr->data;
-
- gdb_event_xfree (event_ptr);
-
- /* Now call the procedure associated with the event. */
- (*proc) (data);
- return 1;
- }
-
- /* This is the case if there are no event on the event queue. */
- return 0;
-}
-