ListenableFuture implementations to manage their listeners. An
instance contains a list of listeners, each with an associated Executor, and guarantees
that every Runnable that is added will be executed after execute() is called. Any Runnable added after the call to execute is still
guaranteed to execute. There is no guarantee, however, that listeners will be executed in the
order that they are added.
Exceptions thrown by a listener will be propagated up to the executor. Any exception thrown
during Executor.execute (e.g., a RejectedExecutionException or an exception
thrown by direct execution) will be caught and logged.
| Modifier and Type | Class and Description |
|---|---|
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| private static final LazyLogger | log
Logger to log exceptions caught when running runnables. |
| private ExecutionList. | runnables
The runnable, executor pairs to execute. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void | |
| private static void | executeListener(Runnable runnable, Executor executor)
Submits the given runnable to the given |
| executed | back to summary |
|---|---|
private boolean executed
| |
| log | back to summary |
|---|---|
| private static final LazyLogger log Logger to log exceptions caught when running runnables. | |
| runnables | back to summary |
|---|---|
| private ExecutionList. The runnable, executor pairs to execute. This acts as a stack threaded through the
| |
| ExecutionList | back to summary |
|---|---|
| public ExecutionList() Creates a new, empty | |
| add | back to summary |
|---|---|
| public void add(Runnable runnable, Executor executor) Adds the When selecting an executor, note that | |
| execute | back to summary |
|---|---|
| public void execute() Runs this execution list, executing all existing pairs in the order they were added. However, note that listeners added after this point may be executed before those previously added, and note that the execution order of all listeners is ultimately chosen by the implementations of the supplied executors. This method is idempotent. Calling it several times in parallel is semantically equivalent to calling it exactly once.
| |
| executeListener | back to summary |
|---|---|
| private static void executeListener(Runnable runnable, Executor executor) Submits the given runnable to the given
| |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv final Executor | |
| pack-priv ExecutionList. | |
| pack-priv final Runnable |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| executor | back to summary |
|---|---|
| pack-priv final Executor executor | |
| next | back to summary |
|---|---|
| pack-priv ExecutionList. | |
| runnable | back to summary |
|---|---|
| pack-priv final Runnable runnable | |
| RunnableExecutorPair | back to summary |
|---|---|
| pack-priv RunnableExecutorPair(Runnable runnable, Executor executor, ExecutionList. | |