By: W.C. Wake, B.D. Wake, E.A. Fox
Published in: PLoPD2
Summary: Design for the low-level structure of interactive applications.
Category: Event-Driven Systems, GUI Development, Interactive Systems, Reactive and Real-Time Systems
Design for the low-level structure of interactive applications.
You're working on an interactive application. The application receives input as events. Build the program around an event queue. For each event in the queue, store the type of event, a time stamp, and event data. Order events by time.
You're using Event Queue but events are arriving faster than the program can handle. At each fetch, see if other events are pending. See whether the next event is compatible with the current one and combine them into a compound event. Repeat to merge all compatible events.
You're using Event Queue but the program has too much to do in response to some events. Add artificial events to the queue. The program handles these events by doing background processing. This may speed up future interaction.
You're using Event Queue. Display is expensive or time-critical. Rather than strictly alternating command execution and result display, separate the two by introducing an output event. Output events can be kept on the regular event queue or a separate queue. Idle events can schedule output event processing.