Class InlineExecutorService
java.lang.Object
org.robolectric.android.util.concurrent.InlineExecutorService
- All Implemented Interfaces:
Executor,ExecutorService
Executor service that executes posted tasks as soon as they are posted.
Intended to be a replacement for RoboExecutorService when using LooperMode.Mode.PAUSED. Unlike RoboExecutorService, will execute tasks on a background
thread. This is useful to test Android code that enforces it runs off the main thread.
Also consider using MoreExecutors.directExecutor(), if your code under test can handle
being called from main thread.
Also see PausedExecutorService if you need control over when posted tasks are
executed.
NOTE: Beta API, subject to change.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanawaitTermination(long l, TimeUnit timeUnit) 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) booleanbooleanvoidshutdown()Future<?><T> Future<T><T> Future<T>
-
Constructor Details
-
InlineExecutorService
public InlineExecutorService()
-
-
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
-
submit
- Specified by:
submitin interfaceExecutorService
-
submit
- Specified by:
submitin interfaceExecutorService
-
execute
-
invokeAll
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException - Specified by:
invokeAllin interfaceExecutorService- Throws:
InterruptedException
-
invokeAll
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException - Specified by:
invokeAllin interfaceExecutorService- Throws:
InterruptedException
-
invokeAny
public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws ExecutionException, InterruptedException - Specified by:
invokeAnyin interfaceExecutorService- Throws:
ExecutionExceptionInterruptedException
-
invokeAny
public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws ExecutionException, InterruptedException, TimeoutException - Specified by:
invokeAnyin interfaceExecutorService- Throws:
ExecutionExceptionInterruptedExceptionTimeoutException
-