Improving Responsiveness in Interactive Applications Using Queues

By: W.C. Wake, B.D. Wake, E.A. Fox
Published in: PLoPD2
Pages: 563-573

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.

Pattern: Event Queue

Pages: 564-566

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.

Pattern: Merge Compatible Events

Pages: 566-568

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.

Pattern: Handle Artificial Events

Pages: 568-570

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.

Pattern: Decouple Execution and Output

Pages: 570-571

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.