Class WrappingExecutorService
java.lang.Object
com.google.common.util.concurrent.WrappingExecutorService
- All Implemented Interfaces:
AutoCloseable
,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 boolean
awaitTermination
(long timeout, TimeUnit unit) final void
invokeAll
(Collection<? extends Callable<T>> tasks) invokeAll
(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) final <T> T
invokeAny
(Collection<? extends Callable<T>> tasks) final <T> T
invokeAny
(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) final boolean
final boolean
final void
shutdown()
final Future
<?> final <T> Future
<T> final <T> Future
<T> protected Runnable
Wraps aRunnable
for submission to the underlying executor.protected abstract <T> Callable
<T> Wraps aCallable
for submission to the underlying executor.private <T> ImmutableList
<Callable<T>> wrapTasks
(Collection<? extends Callable<T>> tasks) Wraps a collection of tasks.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.concurrent.ExecutorService
close
-
Field Details
-
delegate
-
-
Constructor Details
-
WrappingExecutorService
-
-
Method Details
-
wrapTask
Wraps aCallable
for submission to the underlying executor. This method is also applied to anyRunnable
passed to the default implementation ofwrapTask(Runnable)
. -
wrapTask
Wraps aRunnable
for submission to the underlying executor. The default implementation delegates towrapTask(Callable)
. -
wrapTasks
Wraps a collection of tasks.- Throws:
NullPointerException
- if any element oftasks
is null
-
execute
-
submit
- Specified by:
submit
in interfaceExecutorService
-
submit
- Specified by:
submit
in interfaceExecutorService
-
submit
- Specified by:
submit
in interfaceExecutorService
-
invokeAll
public final <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException - Specified by:
invokeAll
in interfaceExecutorService
- Throws:
InterruptedException
-
invokeAll
public final <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException - Specified by:
invokeAll
in interfaceExecutorService
- Throws:
InterruptedException
-
invokeAny
public final <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException - Specified by:
invokeAny
in interfaceExecutorService
- Throws:
InterruptedException
ExecutionException
-
invokeAny
public final <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException - Specified by:
invokeAny
in interfaceExecutorService
- Throws:
InterruptedException
ExecutionException
TimeoutException
-
shutdown
public final void shutdown()- Specified by:
shutdown
in interfaceExecutorService
-
shutdownNow
- Specified by:
shutdownNow
in interfaceExecutorService
-
isShutdown
public final boolean isShutdown()- Specified by:
isShutdown
in interfaceExecutorService
-
isTerminated
public final boolean isTerminated()- Specified by:
isTerminated
in interfaceExecutorService
-
awaitTermination
- Specified by:
awaitTermination
in interfaceExecutorService
- Throws:
InterruptedException
-