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
SerializingExecutor
with the exception that tasks can be enqueued without necessarily executing immediately.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
ListenerCallQueue.Callback<L>
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.Executor
executor
private boolean
isThreadScheduled
private L
listener
private static java.util.logging.Logger
logger
private 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) void
add(ListenerCallQueue.Callback<L> callback)
Enqueues a task to be run.(package private) void
execute()
Executes all listeners added prior to this call, serially and in order.void
run()
-
-
-
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:
run
in interfacejava.lang.Runnable
-
-