Class AbstractListeningExecutorService
- java.lang.Object
 - 
- java.util.concurrent.AbstractExecutorService
 - 
- com.google.common.util.concurrent.AbstractListeningExecutorService
 
 
 
- 
- All Implemented Interfaces:
 ListeningExecutorService,Executor,ExecutorService
@Beta @CanIgnoreReturnValue @GwtIncompatible public abstract class AbstractListeningExecutorService extends AbstractExecutorService implements ListeningExecutorService
AbstractListeningExecutorServiceimplementation that createsListenableFutureinstances for eachRunnableandCallablesubmitted to it. These tasks are run with the abstractexecute(Runnable)method.In addition to
Executor.execute(java.lang.Runnable), subclasses must implement all methods related to shutdown and termination.- Since:
 - 14.0
 - Author:
 - Chris Povirk
 
 
- 
- 
Constructor Summary
Constructors Constructor Description AbstractListeningExecutorService() 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected <T extends @Nullable Object>
RunnableFuture<T>newTaskFor(Runnable runnable, T value)Returns aRunnableFuturefor the given runnable and default value.protected <T extends @Nullable Object>
RunnableFuture<T>newTaskFor(Callable<T> callable)Returns aRunnableFuturefor the given callable task.ListenableFuture<?>submit(Runnable task)Submits a Runnable task for execution and returns a Future representing that task.<T extends @Nullable Object>
ListenableFuture<T>submit(Runnable task, T result)Submits a Runnable task for execution and returns a Future representing that task.<T extends @Nullable Object>
ListenableFuture<T>submit(Callable<T> task)Submits a value-returning task for execution and returns a Future representing the pending results of the task.- 
Methods inherited from class java.util.concurrent.AbstractExecutorService
invokeAll, invokeAll, invokeAny, invokeAny 
- 
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
awaitTermination, invokeAny, invokeAny, isShutdown, isTerminated, shutdown, shutdownNow 
- 
Methods inherited from interface com.google.common.util.concurrent.ListeningExecutorService
invokeAll, invokeAll 
 - 
 
 - 
 
- 
- 
Constructor Detail
- 
AbstractListeningExecutorService
public AbstractListeningExecutorService()
 
 - 
 
- 
Method Detail
- 
newTaskFor
protected final <T extends @Nullable Object> RunnableFuture<T> newTaskFor(Runnable runnable, T value)
Description copied from class:java.util.concurrent.AbstractExecutorServiceReturns aRunnableFuturefor the given runnable and default value.- Overrides:
 newTaskForin classAbstractExecutorService- Type Parameters:
 T- the type of the given value- Parameters:
 runnable- the runnable task being wrappedvalue- the default value for the returned future- Returns:
 - a 
RunnableFuturewhich, when run, will run the underlying runnable and which, as aFuture, will yield the given value as its result and provide for cancellation of the underlying task - Since:
 - 19.0 (present with return type 
ListenableFutureTasksince 14.0) 
 
- 
newTaskFor
protected final <T extends @Nullable Object> RunnableFuture<T> newTaskFor(Callable<T> callable)
Description copied from class:java.util.concurrent.AbstractExecutorServiceReturns aRunnableFuturefor the given callable task.- Overrides:
 newTaskForin classAbstractExecutorService- Type Parameters:
 T- the type of the callable's result- Parameters:
 callable- the callable task being wrapped- Returns:
 - a 
RunnableFuturewhich, when run, will call the underlying callable and which, as aFuture, will yield the callable's result as its result and provide for cancellation of the underlying task - Since:
 - 19.0 (present with return type 
ListenableFutureTasksince 14.0) 
 
- 
submit
public ListenableFuture<?> submit(Runnable task)
Description copied from interface:java.util.concurrent.ExecutorServiceSubmits a Runnable task for execution and returns a Future representing that task. The Future'sgetmethod will returnnullupon successful completion.- Specified by:
 submitin interfaceExecutorService- Specified by:
 submitin interfaceListeningExecutorService- Overrides:
 submitin classAbstractExecutorService- Parameters:
 task- the task to submit- Returns:
 - a Future representing pending completion of the task
 
 
- 
submit
public <T extends @Nullable Object> ListenableFuture<T> submit(Runnable task, T result)
Description copied from interface:java.util.concurrent.ExecutorServiceSubmits a Runnable task for execution and returns a Future representing that task. The Future'sgetmethod will return the given result upon successful completion.- Specified by:
 submitin interfaceExecutorService- Specified by:
 submitin interfaceListeningExecutorService- Overrides:
 submitin classAbstractExecutorService- Type Parameters:
 T- the type of the result- Parameters:
 task- the task to submitresult- the result to return- Returns:
 - a Future representing pending completion of the task
 
 
- 
submit
public <T extends @Nullable Object> ListenableFuture<T> submit(Callable<T> task)
Description copied from interface:java.util.concurrent.ExecutorServiceSubmits a value-returning task for execution and returns a Future representing the pending results of the task. The Future'sgetmethod will return the task's result upon successful completion.If you would like to immediately block waiting for a task, you can use constructions of the form
result = exec.submit(aCallable).get();Note: The
Executorsclass includes a set of methods that can convert some other common closure-like objects, for example,PrivilegedActiontoCallableform so they can be submitted.- Specified by:
 submitin interfaceExecutorService- Specified by:
 submitin interfaceListeningExecutorService- Overrides:
 submitin classAbstractExecutorService- Type Parameters:
 T- the type of the task's result- Parameters:
 task- the task to submit- Returns:
 - a Future representing pending completion of the task
 
 
 - 
 
 -