Class EventQueue<T extends Event>

java.lang.Object
com.diozero.api.sandpit.EventQueue<T>
Type Parameters:
T - the class containing the data fields for individual events
All Implemented Interfaces:
Runnable, Consumer<T>

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

    • EventQueue

      public EventQueue()
  • Method Details

    • addListener

      public void addListener​(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>
    • stop

      public void stop()
    • run

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