code: protected void dispatchEvents() {
  
      while (true) {
  
        Object event = this.eventQueue.poll();
        if (event == null) {
          return;
        }
        Collection<Throwable> errors = new LinkedList<>();
        dispatchEvent(event, errors);
        if (!errors.isEmpty()) {
          handleErrors(errors, event);
        }
      }
    }
docs: Dispatches all events in the event queue.