IT lexicon › Programming › Event queue

Event queue

Programming På svenska → Updated: 2026-10-27

A queue where parts of a game leave messages for each other, so the sender never has to wait for the receiver to get round to them.

Where the observer pattern decouples who talks to whom, a queue also decouples when. Audio is the classic case: gameplay code drops "play explosion" into the queue and carries on, and the audio system drains messages at its own pace, often on its own thread. The queue is usually a fixed-size ring buffer, and duplicates — ten explosions in one frame — can be merged before anything plays.

Robert Nystrom gave the pattern its own chapter in Game Programming Patterns (2014) and was frank about the price. The receiver sees the world as it is when the message is read, not as it was when it was sent, and a system that answers events with more events can build a feedback loop that never empties the queue. The Windows message loop is the same idea at operating-system scale.

← Back to the lexicon