Top Description Inners Fields Constructors Methods
com.google.common.util.concurrent

public final Class ExecutionList

extends Object
Class Inheritance
Annotations
@J2ktIncompatible
@GwtIncompatible
@ElementTypesAreNonnullByDefault
Static Imports
com.google.common.base.Preconditions.checkNotNull

A support class for 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.

Authors
Nishant Thakkar, Sven Mawson
Since
1.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private boolean
private static final LazyLogger
log

Logger to log exceptions caught when running runnables.

private ExecutionList.RunnableExecutorPair
runnables

The runnable, executor pairs to execute.

Constructor Summary

AccessConstructor and Description
public
ExecutionList()

Creates a new, empty ExecutionList.

Method Summary

Modifier and TypeMethod and Description
public void
add(Runnable runnable, Executor executor)

Adds the Runnable and accompanying Executor to the list of listeners to execute.

public void
execute()

Runs this execution list, executing all existing pairs in the order they were added.

private static void
executeListener(Runnable runnable, Executor executor)

Submits the given runnable to the given Executor catching and logging all runtime exceptions thrown by the executor.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

executedback to summary
private boolean executed
Annotations
@GuardedBy:this
logback to summary
private static final LazyLogger log

Logger to log exceptions caught when running runnables.

runnablesback to summary
private ExecutionList.RunnableExecutorPair runnables

The runnable, executor pairs to execute. This acts as a stack threaded through the RunnableExecutorPair#next field.

Annotations
@GuardedBy:this
@CheckForNull

Constructor Detail

ExecutionListback to summary
public ExecutionList()

Creates a new, empty ExecutionList.

Method Detail

addback to summary
public void add(Runnable runnable, Executor executor)

Adds the Runnable and accompanying Executor to the list of listeners to execute. If execution has already begun, the listener is executed immediately.

When selecting an executor, note that directExecutor is dangerous in some cases. See the discussion in the ListenableFuture.addListener documentation.

executeback 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.

Since
10.0 (present in 1.0 as run)
executeListenerback to summary
private static void executeListener(Runnable runnable, Executor executor)

Submits the given runnable to the given Executor catching and logging all runtime exceptions thrown by the executor.

Annotations
@SuppressWarnings:CatchingUnchecked
com.google.common.util.concurrent back to summary

private final Class ExecutionList.RunnableExecutorPair

extends Object
Class Inheritance
  • java.lang.Object
  • com.google.common.util.concurrent.ExecutionList.RunnableExecutorPair

Field Summary

Modifier and TypeField and Description
pack-priv final Executor
pack-priv ExecutionList.RunnableExecutorPair
pack-priv final Runnable

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

executorback to summary
pack-priv final Executor executor
nextback to summary
pack-priv ExecutionList.RunnableExecutorPair next
Annotations
@CheckForNull
runnableback to summary
pack-priv final Runnable runnable

Constructor Detail

RunnableExecutorPairback to summary
pack-priv RunnableExecutorPair(Runnable runnable, Executor executor, ExecutionList.RunnableExecutorPair next)