Next: , Previous: , Up: Events and the Event Loop   [Contents][Index]

13.5 Event Queues

There are two event queues here – the command event queue (#### which should be called "deferred event queue" and is in my glyph ws) and the dispatch event queue. Under X, it’s possible to selectively process events such that we take all the user events before the non-user ones.

The dispatch queue (which used to occur duplicated inside of each event implementation) is used for events that have been read from the window-system event queue(s) and not yet process by next_event_internal(). It exists for two reasons: (1) because in many implementations, events often come from the window system by way of callbacks, and need to push the event to be returned onto a queue; (2) in order to handle QUIT in a guaranteed correct fashion without resorting to weird implementation-specific hacks that may or may not work well, we need to drain the window-system event queues and then look through to see if there’s an event matching quit-char (usually ^G). the drained events need to go onto a queue. (There are other, similar cases where we need to drain the pending events so we can look ahead – for example, checking for pending expose events under X to avoid excessive server activity.)

The command event queue is used AFTER an event has been read from next_event_internal(), when it needs to be pushed back. This includes, for example, accept-process-output, sleep-for and wait_delaying_user_input(). Eval events and the like, generated by enqueue-eval-event, enqueue_magic_eval_event(), etc. are also pushed onto this queue. Some events generated by callbacks are also pushed onto this queue, #### although maybe shouldn’t be.

The command queue takes precedence over the dispatch queue.

#### It is worth investigating to see whether both queues are really needed, and how exactly they should be used. enqueue-eval-event, for example, could certainly push onto the dispatch queue, and all callbacks maybe should. wait_delaying_user_input() seems to need both queues, since it can take events from the dispatch queue and push them onto the command queue; but it perhaps could be rewritten to avoid this. #### In general we need to review the handling of these two queues, figure out exactly what ought to be happening, and document it.

Next: , Previous: , Up: Events and the Event Loop   [Contents][Index]