home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1998 January / PCO0198.ISO / browser / net_linx / java40.jar / netscape / applet / EventQueue.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-11-03  |  1.5 KB  |  75 lines

  1. package netscape.applet;
  2.  
  3. class EventQueue {
  4.    static final int MAX_EVENTS_NUMBER = 400;
  5.    NEvent eventList = new AppletEvent(-1);
  6.    int eventsCount = 0;
  7.  
  8.    public EventQueue() {
  9.    }
  10.  
  11.    public void destroy() {
  12.       this.eventList = null;
  13.    }
  14.  
  15.    public synchronized void sendEvent(NEvent var1) {
  16.       this.eventList.appendElement(var1);
  17.       this.notifyAll();
  18.    }
  19.  
  20.    public synchronized void sendGUIEvent(NEvent var1) {
  21.       if (this.eventsCount <= 400) {
  22.          this.eventList.appendElement(var1);
  23.          ++this.eventsCount;
  24.          this.notifyAll();
  25.       }
  26.  
  27.    }
  28.  
  29.    public synchronized NEvent getNextEvent() {
  30.       Object var1 = null;
  31.  
  32.       while(this.eventList.isEmptyList()) {
  33.          try {
  34.             this.wait();
  35.          } catch (InterruptedException var2) {
  36.             return (NEvent)var1;
  37.          }
  38.       }
  39.  
  40.       NEvent var3 = (NEvent)this.eventList.next;
  41.       ((DoubleLinkedList)var3).remove();
  42.       --this.eventsCount;
  43.       return var3;
  44.    }
  45.  
  46.    public synchronized int getQueueSize() {
  47.       return this.eventsCount;
  48.    }
  49.  
  50.    public synchronized void removeEvents(Object var1) {
  51.       if (!this.eventList.isEmptyList()) {
  52.          for(NEvent var2 = (NEvent)this.eventList.next; var2 != this.eventList; var2 = (NEvent)var2.next) {
  53.             if (var1 == var2.getTarget()) {
  54.                ((DoubleLinkedList)var2).remove();
  55.                --this.eventsCount;
  56.             }
  57.          }
  58.       }
  59.  
  60.    }
  61.  
  62.    public synchronized void coalesceEvent(NEvent var1) {
  63.       if (!this.eventList.isEmptyList()) {
  64.          for(NEvent var2 = (NEvent)this.eventList.next; var2 != this.eventList; var2 = (NEvent)var2.next) {
  65.             if (var1.coalesce(var2)) {
  66.                ((DoubleLinkedList)var2).remove();
  67.                --this.eventsCount;
  68.                return;
  69.             }
  70.          }
  71.       }
  72.  
  73.    }
  74. }
  75.