@Test public void testUpdate () { EventManager manager = new EventManager("test", false); AtomicBoolean b = new AtomicBoolean(false); AtomicInteger count = new AtomicInteger(0); EventListener listener = new EventListener() { @Override public void handleEvent(EventData eventData) { b.set(true); count.incrementAndGet(); try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } } }; manager.addListener(1, listener); DummyEventDataObject event = new DummyEventDataObject(); assertEquals(1, event.getRefCount()); manager.queueEvent(event); manager.queueEvent(new DummyEventDataObject()); manager.queueEvent(new DummyOtherEventDataObject()); manager.update(); assertEquals(true, b.get()); assertEquals(2, count.get()); assertEquals(1, event.getRefCount()); assertNull(manager.eventQueue[0].poll()); assertNull(manager.eventQueue[1].poll()); }
public void update () { this.update(Integer.MAX_VALUE); }
EventManager { public void update () { this.update(Integer.MAX_VALUE); } }
EventManager { public void update () { this.update(Integer.MAX_VALUE); } EventManager(String name, boolean setAsGlobal); }
EventManager { public void update () { this.update(Integer.MAX_VALUE); } EventManager(String name, boolean setAsGlobal); void update(); void update(int maxMillis); void queueEvent(EventData event); void triggerEvent(EventData event); void addListener(int typeID, EventListener<T> listener); void removeListener(int typeID, EventListener<T> listener); static final EventManager getInstance(); }
EventManager { public void update () { this.update(Integer.MAX_VALUE); } EventManager(String name, boolean setAsGlobal); void update(); void update(int maxMillis); void queueEvent(EventData event); void triggerEvent(EventData event); void addListener(int typeID, EventListener<T> listener); void removeListener(int typeID, EventListener<T> listener); static final EventManager getInstance();  }