Class AbstractListeningExecutorService
-
-
- com.google.common.util.concurrent.AbstractListeningExecutorService
-
-
- All Implemented Interfaces:
,
@Beta @GwtIncompatible public abstract class AbstractListeningExecutorService extends implements ListeningExecutorService
AbstractListeningExecutorService
implementation that createsListenableFuture
instances for each and submitted to it. These tasks are run with the abstract method.In addition to , 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> <T>
runnable, T value)
Returns aRunnableFuture
for the given runnable and default value.protected <T> <T>
<T> callable)
Returns aRunnableFuture
for the given callable task.ListenableFuture<?>
task)
Submits a Runnable task for execution and returns a Future representing that task.<T> ListenableFuture<T>
task, T result)
Submits a Runnable task for execution and returns a Future representing that task.<T> ListenableFuture<T>
<T> task)
Submits a value-returning task for execution and returns a Future representing the pending results of the task.-
Methods inherited from interface com.google.common.util.concurrent.ListeningExecutorService
invokeAll, invokeAll
-
-
-
-
Constructor Detail
-
AbstractListeningExecutorService
public AbstractListeningExecutorService()
-
-
Method Detail
-
newTaskFor
protected final <T> <T> runnable, T value)
Description copied from class:Returns aRunnableFuture
for the given runnable and default value.- Overrides:
in class
- 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
RunnableFuture
which, 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
ListenableFutureTask
since 14.0)
-
newTaskFor
protected final <T> <T> <T> callable)
Description copied from class:Returns aRunnableFuture
for the given callable task.- Overrides:
in class
- Type Parameters:
T
- the type of the callable's result- Parameters:
callable
- the callable task being wrapped- Returns:
- a
RunnableFuture
which, 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
ListenableFutureTask
since 14.0)
-
submit
public task)
Description copied from interface:Submits a Runnable task for execution and returns a Future representing that task. The Future'sget
method will returnnull
upon successful completion.- Specified by:
in interface
- Specified by:
submit
in interfaceListeningExecutorService
- Overrides:
in class
- Parameters:
task
- the task to submit- Returns:
- a Future representing pending completion of the task
-
submit
public <T> task, T result)
Description copied from interface:Submits a Runnable task for execution and returns a Future representing that task. The Future'sget
method will return the given result upon successful completion.- Specified by:
in interface
- Specified by:
submit
in interfaceListeningExecutorService
- Overrides:
in class
- 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> <T> task)
Description copied from interface:Submits a value-returning task for execution and returns a Future representing the pending results of the task. The Future'sget
method 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 class includes a set of methods that can convert some other common closure-like objects, for example, to form so they can be submitted.
- Specified by:
in interface
- Specified by:
submit
in interfaceListeningExecutorService
- Overrides:
in class
- 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
-
-