Class SameThreadScheduledExecutorService
java.lang.Object
java.util.concurrent.AbstractExecutorService
com.google.common.util.concurrent.testing.SameThreadScheduledExecutorService
- All Implemented Interfaces:
ListeningExecutorService,ListeningScheduledExecutorService,AutoCloseable,Executor,ExecutorService,ScheduledExecutorService
class SameThreadScheduledExecutorService
extends 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 ClassesModifier and TypeClassDescriptionprivate static final class -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanawaitTermination(long timeout, TimeUnit unit) voidinvokeAll(Collection<? extends Callable<T>> tasks) invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) <T> TinvokeAny(Collection<? extends Callable<T>> tasks) <T> TinvokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) booleanboolean<V> ListenableScheduledFuture<V> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit) voidshutdown()<T> ListenableFuture<T> <T> ListenableFuture<T> Methods inherited from class java.util.concurrent.AbstractExecutorService
newTaskFor, newTaskForMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.concurrent.ExecutorService
closeMethods inherited from interface com.google.common.util.concurrent.ListeningExecutorService
awaitTermination, invokeAll, invokeAnyMethods inherited from interface com.google.common.util.concurrent.ListeningScheduledExecutorService
schedule, schedule, scheduleAtFixedRate, scheduleWithFixedDelay
-
Field Details
-
delegate
-
-
Constructor Details
-
SameThreadScheduledExecutorService
SameThreadScheduledExecutorService()
-
-
Method Details
-
shutdown
public void shutdown()- Specified by:
shutdownin interfaceExecutorService
-
shutdownNow
- Specified by:
shutdownNowin interfaceExecutorService
-
isShutdown
public boolean isShutdown()- Specified by:
isShutdownin interfaceExecutorService
-
isTerminated
public boolean isTerminated()- Specified by:
isTerminatedin interfaceExecutorService
-
awaitTermination
- Specified by:
awaitTerminationin interfaceExecutorService- Throws:
InterruptedException
-
submit
- Specified by:
submitin interfaceExecutorService- Specified by:
submitin interfaceListeningExecutorService- Overrides:
submitin classAbstractExecutorService- Returns:
- a
ListenableFuturerepresenting pending completion of the task
-
submit
- Specified by:
submitin interfaceExecutorService- Specified by:
submitin interfaceListeningExecutorService- Overrides:
submitin classAbstractExecutorService- Returns:
- a
ListenableFuturerepresenting pending completion of the task
-
submit
- Specified by:
submitin interfaceExecutorService- Specified by:
submitin interfaceListeningExecutorService- Overrides:
submitin classAbstractExecutorService- Returns:
- a
ListenableFuturerepresenting pending completion of the task
-
invokeAll
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException Description 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 interfaceExecutorService- Specified by:
invokeAllin interfaceListeningExecutorService- Overrides:
invokeAllin classAbstractExecutorService- 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:
InterruptedException
-
invokeAll
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException Description 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 interfaceExecutorService- Specified by:
invokeAllin interfaceListeningExecutorService- Overrides:
invokeAllin classAbstractExecutorService- 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:
InterruptedException
-
invokeAny
public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException - Specified by:
invokeAnyin interfaceExecutorService- Overrides:
invokeAnyin classAbstractExecutorService- Throws:
InterruptedExceptionExecutionException
-
invokeAny
public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException - Specified by:
invokeAnyin interfaceExecutorService- Overrides:
invokeAnyin classAbstractExecutorService- Throws:
InterruptedExceptionExecutionExceptionTimeoutException
-
execute
-
schedule
- Specified by:
schedulein interfaceListeningScheduledExecutorService- Specified by:
schedulein interfaceScheduledExecutorService
-
schedule
- Specified by:
schedulein interfaceListeningScheduledExecutorService- Specified by:
schedulein interfaceScheduledExecutorService
-
scheduleAtFixedRate
public ListenableScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) - Specified by:
scheduleAtFixedRatein interfaceListeningScheduledExecutorService- Specified by:
scheduleAtFixedRatein interfaceScheduledExecutorService
-
scheduleWithFixedDelay
public ListenableScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit) - Specified by:
scheduleWithFixedDelayin interfaceListeningScheduledExecutorService- Specified by:
scheduleWithFixedDelayin interfaceScheduledExecutorService
-