Class EventQueue<T extends Event>

  • Type Parameters:
    T - the class containing the data fields for individual events
    All Implemented Interfaces:
    AutoCloseable, Runnable, Consumer<T>

    public class EventQueue<T extends Event>
    extends Object
    implements Consumer<T>, Runnable, AutoCloseable
    Decouple event producers from consumers so that event production isn't affected by event consumption
    • Constructor Detail

      • EventQueue

        public EventQueue()
    • Method Detail

      • addListener

        public void addListener​(Consumer<T> listener)
      • removeListener

        public void removeListener​(Consumer<T> listener)
      • accept

        public void accept​(T t)
        Adds an element to the tail of the queue
        Specified by:
        accept in interface Consumer<T extends Event>
      • start

        public void start()
      • run

        public void run()
        Specified by:
        run in interface Runnable
      • stop

        public void stop()