Uploaded image for project: 'Apache Lens (Retired)'
  1. Apache Lens (Retired)
  2. LENS-1299

Thread should have ability to wait for Events to be processed

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Duplicate
    • None
    • 2.7
    • None
    • None

    Description

      When a thread notifies event service to process any event, it should have a way to wait for it to be finished.

      LensEvent event = new LensEvent();
      synchronized(event) {
         eventservice.notifyEvent(event);
         event.wait();
      }
      

      The EventHandler will do a notifyall() on the event it is done handling.

      public void run() {
            try {
              Class<? extends LensEvent> evtClass = event.getClass();
              // Call listeners directly listening for this event type
              handleEvent(eventListeners.get(evtClass), event);
              Class<?> superClass = evtClass.getSuperclass();
      
              // Call listeners which listen of super types of this event type
              while (LensEvent.class.isAssignableFrom(superClass)) {
                if (eventListeners.containsKey(superClass)) {
                  handleEvent(eventListeners.get(superClass), event);
                }
                superClass = superClass.getSuperclass();
              }
            } finally {
              synchronized (event) {
                event.notifyAll();
              }
            }
          }
      

      Attachments

        Issue Links

          Activity

            People

              lavkesh Lavkesh Lahngir
              lavkesh Lavkesh Lahngir
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: