Class WrappingExecutorService
java.lang.Object
com.google.common.util.concurrent.WrappingExecutorService
- All Implemented Interfaces:
Executor,ExecutorService
- Direct Known Subclasses:
WrappingScheduledExecutorService
An abstract
ExecutorService that allows subclasses to wrap tasks before they are submitted to the underlying executor.
Note that task wrapping may occur even if the task is never executed.
For delegation without task-wrapping, see ForwardingExecutorService.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanawaitTermination(long timeout, TimeUnit unit) final voidinvokeAll(Collection<? extends Callable<T>> tasks) invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) final <T> TinvokeAny(Collection<? extends Callable<T>> tasks) final <T> TinvokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) final booleanfinal booleanfinal voidshutdown()final Future<?>final <T> Future<T>final <T> Future<T>protected RunnableWraps aRunnablefor submission to the underlying executor.protected abstract <T> Callable<T>Wraps aCallablefor submission to the underlying executor.private <T> ImmutableList<Callable<T>>wrapTasks(Collection<? extends Callable<T>> tasks) Wraps a collection of tasks.
-
Field Details
-
delegate
-
-
Constructor Details
-
WrappingExecutorService
-
-
Method Details
-
wrapTask
Wraps aCallablefor submission to the underlying executor. This method is also applied to anyRunnablepassed to the default implementation ofwrapTask(Runnable). -
wrapTask
Wraps aRunnablefor submission to the underlying executor. The default implementation delegates towrapTask(Callable). -
wrapTasks
Wraps a collection of tasks.- Throws:
NullPointerException- if any element oftasksis null
-
execute
-
submit
- Specified by:
submitin interfaceExecutorService
-
submit
- Specified by:
submitin interfaceExecutorService
-
submit
- Specified by:
submitin interfaceExecutorService
-
invokeAll
public final <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException - Specified by:
invokeAllin interfaceExecutorService- Throws:
InterruptedException
-
invokeAll
public final <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException - Specified by:
invokeAllin interfaceExecutorService- Throws:
InterruptedException
-
invokeAny
public final <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException - Specified by:
invokeAnyin interfaceExecutorService- Throws:
InterruptedExceptionExecutionException
-
invokeAny
public final <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException - Specified by:
invokeAnyin interfaceExecutorService- Throws:
InterruptedExceptionExecutionExceptionTimeoutException
-
shutdown
public final void shutdown()- Specified by:
shutdownin interfaceExecutorService
-
shutdownNow
- Specified by:
shutdownNowin interfaceExecutorService
-
isShutdown
public final boolean isShutdown()- Specified by:
isShutdownin interfaceExecutorService
-
isTerminated
public final boolean isTerminated()- Specified by:
isTerminatedin interfaceExecutorService
-
awaitTermination
- Specified by:
awaitTerminationin interfaceExecutorService- Throws:
InterruptedException
-