Package com.diozero.api.sandpit
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:
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 Summary
Constructors Constructor Description EventQueue()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
accept(T t)
Adds an element to the tail of the queuevoid
addListener(Consumer<T> listener)
void
close()
void
removeListener(Consumer<T> listener)
void
run()
void
start()
void
stop()
-
-
-
Method Detail
-
accept
public void accept(T t)
Adds an element to the tail of the queue
-
start
public void start()
-
stop
public void stop()
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
-
-