Resources | developer.brewmp.com Resources | developer.brewmp.com

Developer

resources

Event handling considerations

  • A backlog in the event queue translates into perceived delay for the user.
  • Validate that the event arrival rate of your design, combined with the other system events, can be processed by the system without a queue becoming so deep that it impacts the user's perception of responsiveness, or that the system elects to drop events.
  • When exceeding this threshold, one needs to consider if the event being processed is more optimally treated as data. Touch screen events are a common example. Handwriting recognition improves with the number of samples per second. Treating every sample as an event can flood the event handling mechanism. Grouping events into a list of data, with a time derived event, can improve performance.
  • Event prioritization and/or creating independent UI tasks can have an advantage. Take the example of a single-threaded UI downloading a web page. In an extreme example, if single threaded and polling a queue, the page download is not interruptible until the download is complete.
  • Do not use the event queue as a polling mechanism. For example, in Brew MP, an application should not post an event to itself to check conditions in the event handler, and then re-post the same event if the condition has not been satisfied yet. To periodically check a condition, use a timer with a non-zero delay and check the conditions in the timer callback handler.