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

public abstract Class AbstractListeningExecutorService

extends AbstractExecutorService
implements ListeningExecutorService
Class Inheritance
All Implemented Interfaces
com.google.common.util.concurrent.ListeningExecutorService, java.util.concurrent.ExecutorService, java.lang.AutoCloseable, java.util.concurrent.Executor
Known Direct Subclasses
com.google.common.util.concurrent.MoreExecutors.DirectExecutorService, com.google.common.util.concurrent.MoreExecutors.ListeningDecorator
Annotations
@CheckReturnValue
@GwtIncompatible
@J2ktIncompatible
@ElementTypesAreNonnullByDefault
Imports
com.google.common.annotations.GwtIncompatible, .J2ktIncompatible, com.google.errorprone.annotations.CanIgnoreReturnValue, .CheckReturnValue, java.util.concurrent.AbstractExecutorService, .Callable, .RunnableFuture, org.checkerframework.checker.nullness.qual.Nullable

Abstract ListeningExecutorService implementation that creates ListenableFuture instances for each Runnable and Callable submitted to it. These tasks are run with the abstract execute(Runnable) method.

In addition to execute, subclasses must implement all methods related to shutdown and termination.

Author
Chris Povirk
Since
14.0

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected final <T extends @Nullable Object> RunnableFuture<T>
newTaskFor(Runnable
the runnable task being wrapped
runnable
,
T
the default value for the returned future
value
)

Overrides java.util.concurrent.AbstractExecutorService.newTaskFor.

Returns a RunnableFuture for the given runnable and default value.
protected final <T extends @Nullable Object> RunnableFuture<T>
newTaskFor(Callable<T>
the callable task being wrapped
callable
)

Overrides java.util.concurrent.AbstractExecutorService.newTaskFor.

Returns a RunnableFuture for the given callable task.
public ListenableFuture<?>
submit(Runnable
the task to submit
task
)

Overrides java.util.concurrent.AbstractExecutorService.submit.

Implements com.google.common.util.concurrent.ListeningExecutorService.submit, java.util.concurrent.ExecutorService.submit.

Submits a Runnable task for execution and returns a Future representing that task.
public <T extends @Nullable Object> ListenableFuture<T>
submit(Runnable
the task to submit
task
,
T
the result to return
result
)

Overrides java.util.concurrent.AbstractExecutorService.submit.

Implements com.google.common.util.concurrent.ListeningExecutorService.submit, java.util.concurrent.ExecutorService.submit.

Submits a Runnable task for execution and returns a Future representing that task.
public <T extends @Nullable Object> ListenableFuture<T>
submit(Callable<T>
the task to submit
task
)

Overrides java.util.concurrent.AbstractExecutorService.submit.

Implements com.google.common.util.concurrent.ListeningExecutorService.submit, java.util.concurrent.ExecutorService.submit.

Submits a value-returning task for execution and returns a Future representing the pending results of the task.
Inherited from java.util.concurrent.AbstractExecutorService:
invokeAllinvokeAllinvokeAnyinvokeAny

Constructor Detail

AbstractListeningExecutorServiceback to summary
public AbstractListeningExecutorService()

Method Detail

newTaskForback to summary
protected final <T extends @Nullable Object> RunnableFuture<T> newTaskFor(Runnable runnable, T value)

Overrides java.util.concurrent.AbstractExecutorService.newTaskFor.

Doc from java.util.concurrent.AbstractExecutorService.newTaskFor.

Returns a RunnableFuture for the given runnable and default value.

Parameters
<T>
the type of the given value
runnable:Runnable

the runnable task being wrapped

value:T

the default value for the returned future

Returns:RunnableFuture<T>

a RunnableFuture which, when run, will run the underlying runnable and which, as a Future, will yield the given value as its result and provide for cancellation of the underlying task

Annotations
@CanIgnoreReturnValue
@Override
Since
19.0 (present with return type ListenableFutureTask since 14.0)
newTaskForback to summary
protected final <T extends @Nullable Object> RunnableFuture<T> newTaskFor(Callable<T> callable)

Overrides java.util.concurrent.AbstractExecutorService.newTaskFor.

Doc from java.util.concurrent.AbstractExecutorService.newTaskFor.

Returns a RunnableFuture for the given callable task.

Parameters
<T>
the type of the callable's result
callable:Callable<T>

the callable task being wrapped

Returns:RunnableFuture<T>

a RunnableFuture which, when run, will call the underlying callable and which, as a Future, will yield the callable's result as its result and provide for cancellation of the underlying task

Annotations
@CanIgnoreReturnValue
@Override
Since
19.0 (present with return type ListenableFutureTask since 14.0)
submitback to summary
public ListenableFuture<?> submit(Runnable task)

Overrides java.util.concurrent.AbstractExecutorService.submit.

Implements com.google.common.util.concurrent.ListeningExecutorService.submit, java.util.concurrent.ExecutorService.submit.

Doc from java.util.concurrent.ExecutorService.submit.

Submits a Runnable task for execution and returns a Future representing that task. The Future's get method will return null upon successful completion.

Parameters
task:Runnable

the task to submit

Returns:ListenableFuture<?>

Doc from com.google.common.util.concurrent.ListeningExecutorService.submit.

a ListenableFuture representing pending completion of the task

Annotations
@CanIgnoreReturnValue
@Override
submitback to summary
public <T extends @Nullable Object> ListenableFuture<T> submit(Runnable task, T result)

Overrides java.util.concurrent.AbstractExecutorService.submit.

Implements com.google.common.util.concurrent.ListeningExecutorService.submit, java.util.concurrent.ExecutorService.submit.

Doc from java.util.concurrent.ExecutorService.submit.

Submits a Runnable task for execution and returns a Future representing that task. The Future's get method will return the given result upon successful completion.

Parameters
<T>
the type of the result
task:Runnable

the task to submit

result:T

the result to return

Returns:ListenableFuture<T>

Doc from com.google.common.util.concurrent.ListeningExecutorService.submit.

a ListenableFuture representing pending completion of the task

Annotations
@CanIgnoreReturnValue
@Override
submitback to summary
public <T extends @Nullable Object> ListenableFuture<T> submit(Callable<T> task)

Overrides java.util.concurrent.AbstractExecutorService.submit.

Implements com.google.common.util.concurrent.ListeningExecutorService.submit, java.util.concurrent.ExecutorService.submit.

Doc from java.util.concurrent.ExecutorService.submit.

Submits a value-returning task for execution and returns a Future representing the pending results of the task. The Future's get 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 Executors class includes a set of methods that can convert some other common closure-like objects, for example, java.security.PrivilegedAction to Callable form so they can be submitted.

Parameters
<T>
the type of the task's result
task:Callable<T>

the task to submit

Returns:ListenableFuture<T>

Doc from com.google.common.util.concurrent.ListeningExecutorService.submit.

a ListenableFuture representing pending completion of the task

Annotations
@CanIgnoreReturnValue
@Override