Typically, I would implement a thread pool here to handle the processing, while an event observer would just watch the events and pass them to the pool. Example:
(event happens) -> Watcher registers the event -> puts it into the thread pool queue -> thread pool processes the event
Thus, the observer will spend minimal time outside the waiting part, thereby significantly reducing the likelihood of skipping the update.
source share