The event queue behavioral pattern allows you to keep track of work that needs to be done and let some other code actually perform the task.
You get several benefits from this pattern:
- Code that has an interesting event doesn’t need to wait for any work that needs to be done to handle the event to complete and can just post an event and continue.
- Normally, events are handled on a first-in, first-out order but your code can change this if needed. The code that’s posting an event doesn’t need to worry about the order.
- An event queue decouples the sender of events from the handlers and allows each to proceed at their on pace.
- Event queues can be handled locally by a single object or can be distributed where many different objects use the queue to pull work from.