Class SameThreadScheduledExecutorService
- java.lang.Object
-
- java.util.concurrent.AbstractExecutorService
-
- com.google.common.util.concurrent.testing.SameThreadScheduledExecutorService
-
- All Implemented Interfaces:
ListeningExecutorService,ListeningScheduledExecutorService,java.util.concurrent.Executor,java.util.concurrent.ExecutorService,java.util.concurrent.ScheduledExecutorService
@GwtIncompatible class SameThreadScheduledExecutorService extends java.util.concurrent.AbstractExecutorService implements ListeningScheduledExecutorService
A ScheduledExecutorService that executes all scheduled actions immediately in the calling thread.See
TestingExecutors.sameThreadScheduledExecutor()for a full list of constraints.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classSameThreadScheduledExecutorService.ImmediateScheduledFuture<V>
-
Field Summary
Fields Modifier and Type Field Description private ListeningExecutorServicedelegate
-
Constructor Summary
Constructors Constructor Description SameThreadScheduledExecutorService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanawaitTermination(long timeout, java.util.concurrent.TimeUnit unit)voidexecute(java.lang.Runnable command)<T> java.util.List<java.util.concurrent.Future<T>>invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks)<T> java.util.List<java.util.concurrent.Future<T>>invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks, long timeout, java.util.concurrent.TimeUnit unit)<T> TinvokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks)<T> TinvokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks, long timeout, java.util.concurrent.TimeUnit unit)booleanisShutdown()booleanisTerminated()ListenableScheduledFuture<?>schedule(java.lang.Runnable command, long delay, java.util.concurrent.TimeUnit unit)<V> ListenableScheduledFuture<V>schedule(java.util.concurrent.Callable<V> callable, long delay, java.util.concurrent.TimeUnit unit)ListenableScheduledFuture<?>scheduleAtFixedRate(java.lang.Runnable command, long initialDelay, long period, java.util.concurrent.TimeUnit unit)ListenableScheduledFuture<?>scheduleWithFixedDelay(java.lang.Runnable command, long initialDelay, long delay, java.util.concurrent.TimeUnit unit)voidshutdown()java.util.List<java.lang.Runnable>shutdownNow()ListenableFuture<?>submit(java.lang.Runnable task)<T> ListenableFuture<T>submit(java.lang.Runnable task, T result)<T> ListenableFuture<T>submit(java.util.concurrent.Callable<T> task)
-
-
-
Field Detail
-
delegate
private final ListeningExecutorService delegate
-
-
Method Detail
-
shutdown
public void shutdown()
- Specified by:
shutdownin interfacejava.util.concurrent.ExecutorService
-
shutdownNow
public java.util.List<java.lang.Runnable> shutdownNow()
- Specified by:
shutdownNowin interfacejava.util.concurrent.ExecutorService
-
isShutdown
public boolean isShutdown()
- Specified by:
isShutdownin interfacejava.util.concurrent.ExecutorService
-
isTerminated
public boolean isTerminated()
- Specified by:
isTerminatedin interfacejava.util.concurrent.ExecutorService
-
awaitTermination
public boolean awaitTermination(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException- Specified by:
awaitTerminationin interfacejava.util.concurrent.ExecutorService- Throws:
java.lang.InterruptedException
-
submit
public <T> ListenableFuture<T> submit(java.util.concurrent.Callable<T> task)
- Specified by:
submitin interfacejava.util.concurrent.ExecutorService- Specified by:
submitin interfaceListeningExecutorService- Overrides:
submitin classjava.util.concurrent.AbstractExecutorService- Returns:
- a
ListenableFuturerepresenting pending completion of the task
-
submit
public <T> ListenableFuture<T> submit(java.lang.Runnable task, T result)
- Specified by:
submitin interfacejava.util.concurrent.ExecutorService- Specified by:
submitin interfaceListeningExecutorService- Overrides:
submitin classjava.util.concurrent.AbstractExecutorService- Returns:
- a
ListenableFuturerepresenting pending completion of the task
-
submit
public ListenableFuture<?> submit(java.lang.Runnable task)
- Specified by:
submitin interfacejava.util.concurrent.ExecutorService- Specified by:
submitin interfaceListeningExecutorService- Overrides:
submitin classjava.util.concurrent.AbstractExecutorService- Returns:
- a
ListenableFuturerepresenting pending completion of the task
-
invokeAll
public <T> java.util.List<java.util.concurrent.Future<T>> invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks) throws java.lang.InterruptedExceptionDescription copied from interface:ListeningExecutorServiceAll elements in the returned list must be
ListenableFutureinstances. The easiest way to obtain aList<ListenableFuture<T>>from this method is an unchecked (but safe) cast:@SuppressWarnings("unchecked") // guaranteed by invokeAll contractList<ListenableFuture<T>> futures = (List) executor.invokeAll(tasks);- Specified by:
invokeAllin interfacejava.util.concurrent.ExecutorService- Specified by:
invokeAllin interfaceListeningExecutorService- Overrides:
invokeAllin classjava.util.concurrent.AbstractExecutorService- Returns:
- A list of
ListenableFutureinstances representing the tasks, in the same sequential order as produced by the iterator for the given task list, each of which has completed. - Throws:
java.lang.InterruptedException
-
invokeAll
public <T> java.util.List<java.util.concurrent.Future<T>> invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks, long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedExceptionDescription copied from interface:ListeningExecutorServiceAll elements in the returned list must be
ListenableFutureinstances. The easiest way to obtain aList<ListenableFuture<T>>from this method is an unchecked (but safe) cast:@SuppressWarnings("unchecked") // guaranteed by invokeAll contractList<ListenableFuture<T>> futures = (List) executor.invokeAll(tasks, timeout, unit);- Specified by:
invokeAllin interfacejava.util.concurrent.ExecutorService- Specified by:
invokeAllin interfaceListeningExecutorService- Overrides:
invokeAllin classjava.util.concurrent.AbstractExecutorService- Returns:
- a list of
ListenableFutureinstances representing the tasks, in the same sequential order as produced by the iterator for the given task list. If the operation did not time out, each task will have completed. If it did time out, some of these tasks will not have completed. - Throws:
java.lang.InterruptedException
-
invokeAny
public <T> T invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException- Specified by:
invokeAnyin interfacejava.util.concurrent.ExecutorService- Overrides:
invokeAnyin classjava.util.concurrent.AbstractExecutorService- Throws:
java.lang.InterruptedExceptionjava.util.concurrent.ExecutionException
-
invokeAny
public <T> T invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks, long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException- Specified by:
invokeAnyin interfacejava.util.concurrent.ExecutorService- Overrides:
invokeAnyin classjava.util.concurrent.AbstractExecutorService- Throws:
java.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionjava.util.concurrent.TimeoutException
-
execute
public void execute(java.lang.Runnable command)
- Specified by:
executein interfacejava.util.concurrent.Executor
-
schedule
public ListenableScheduledFuture<?> schedule(java.lang.Runnable command, long delay, java.util.concurrent.TimeUnit unit)
- Specified by:
schedulein interfaceListeningScheduledExecutorService- Specified by:
schedulein interfacejava.util.concurrent.ScheduledExecutorService
-
schedule
public <V> ListenableScheduledFuture<V> schedule(java.util.concurrent.Callable<V> callable, long delay, java.util.concurrent.TimeUnit unit)
- Specified by:
schedulein interfaceListeningScheduledExecutorService- Specified by:
schedulein interfacejava.util.concurrent.ScheduledExecutorService
-
scheduleAtFixedRate
public ListenableScheduledFuture<?> scheduleAtFixedRate(java.lang.Runnable command, long initialDelay, long period, java.util.concurrent.TimeUnit unit)
- Specified by:
scheduleAtFixedRatein interfaceListeningScheduledExecutorService- Specified by:
scheduleAtFixedRatein interfacejava.util.concurrent.ScheduledExecutorService
-
scheduleWithFixedDelay
public ListenableScheduledFuture<?> scheduleWithFixedDelay(java.lang.Runnable command, long initialDelay, long delay, java.util.concurrent.TimeUnit unit)
- Specified by:
scheduleWithFixedDelayin interfaceListeningScheduledExecutorService- Specified by:
scheduleWithFixedDelayin interfacejava.util.concurrent.ScheduledExecutorService
-
-