Class ListenerCallQueue<L>
- java.lang.Object
-
- com.google.common.util.concurrent.ListenerCallQueue<L>
-
- All Implemented Interfaces:
java.lang.Runnable
@GwtIncompatible final class ListenerCallQueue<L> extends java.lang.Object implements java.lang.Runnable
A special purpose queue/executor that executes listener callbacks serially on a configured executor. Each callback task can be enqueued and executed as separate phases.This class is very similar to
SerializingExecutorwith the exception that tasks can be enqueued without necessarily executing immediately.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classListenerCallQueue.Callback<L>
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.Executorexecutorprivate booleanisThreadScheduledprivate Llistenerprivate static java.util.logging.Loggerloggerprivate java.util.Queue<ListenerCallQueue.Callback<L>>waitQueue
-
Constructor Summary
Constructors Constructor Description ListenerCallQueue(L listener, java.util.concurrent.Executor executor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidadd(ListenerCallQueue.Callback<L> callback)Enqueues a task to be run.(package private) voidexecute()Executes all listeners added prior to this call, serially and in order.voidrun()
-
-
-
Field Detail
-
logger
private static final java.util.logging.Logger logger
-
listener
private final L listener
-
executor
private final java.util.concurrent.Executor executor
-
waitQueue
private final java.util.Queue<ListenerCallQueue.Callback<L>> waitQueue
-
isThreadScheduled
private boolean isThreadScheduled
-
-
Constructor Detail
-
ListenerCallQueue
ListenerCallQueue(L listener, java.util.concurrent.Executor executor)
-
-
Method Detail
-
add
void add(ListenerCallQueue.Callback<L> callback)
Enqueues a task to be run.
-
execute
void execute()
Executes all listeners added prior to this call, serially and in order.
-
run
public void run()
- Specified by:
runin interfacejava.lang.Runnable
-
-